MCPcopy Index your code
hub / github.com/OpenRL-Lab/Wandb_Tutorial / preprocess

Function preprocess

artifact/load_data.py:48–62  ·  view source on GitHub ↗

## Prepare the data

(dataset, normalize=True, expand_dims=True)

Source from the content-addressed store, hash-verified

46
47
48def preprocess(dataset, normalize=True, expand_dims=True):
49 """
50 ## Prepare the data
51 """
52 x, y = dataset.tensors
53
54 if normalize:
55 # Scale images to the [0, 1] range
56 x = x.type(torch.float32) / 255
57
58 if expand_dims:
59 # Make sure images have shape (1, 28, 28)
60 x = torch.unsqueeze(x, 1)
61
62 return TensorDataset(x, y)
63
64
65def read(data_dir, split):

Callers 1

test_download_artifactFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_download_artifactFunction · 0.72