<jupyter_start><jupyter_text>Transofrmations<jupyter_code>import mxnet as mx
from mxnet import gluon, nd
def transform_fn(data, label):
    data = data.astype('float32')/255
    return data, label
train_dataset = gluon.data.vision.datasets.MNIST(train=True).transform(transform_fn)
train_dataset = gluon.data.vision.datasets.MNIST(train=False).transform(transform_fn)

sample_image = train_dataset[19][0]
nd.max(sample_image)
from mxnet.gluon.data.vision import transforms
train_dataset = gluon.data.vision.datasets.MNIST(train=True)
train_dataset[19][0].shape
train_dataset = train_dataset.transform_first(transforms.ToTensor())
train_dataset[19][0].shape
# normalize
mean, std = (0.1307,),(0.3081,)
normalize = transforms.Normalize(mean, std)
train_dataset = train_dataset.transform_first(normalize)
# compose
transform_fn = transforms.Compose([transforms.ToTensor(),
                                  transforms.Normalize(mean, std)])
train_dataset = gluon.data.vision.datasets.MNIST(train=True).transform(transform_fn)<jupyter_output><empty_output><jupyter_text>Data Loaders<jupyter_code>import mxnet as mx
from mxnet import gluon, nd
from matplotlib.pyplot import imshow
%matplotlib inline
mx.random.seed(42)
x = mx.random.uniform(shape=(10,3))
y = mx.random.uniform(shape=(10,1))
dataset = gluon.data.dataset.ArrayDataset(x,y)
data_loader = gluon.data.DataLoader(dataset, batch_size=5, last_batch='keep')
for x_batch, y_batch in data_loader:
    print('x_batch has shape {}, and y_batch has shape {}'.format(x_batch.shape, y_batch.shape))
train_dataset = gluon.data.vision.datasets.MNIST(train=True)
transform_fn = transforms.Compose([transforms.RandomFlipTopBottom(),
                                  transforms.RandomFlipLeftRight()])
train_dataloader = gluon.data.DataLoader(train_dataset.transform_first(transform_fn), batch_size=5, shuffle=True)
for x_batch, y_batch in train_dataloader:
    imshow(x_batch[3,:,:,0].asnumpy(), cmap='gray')
    break<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12405826217980914, 'fraction_numerical': 0.01808136614766449, 'mean_word_length': 6.139784946236559, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '343161', 'license': 'Apache-2.0', 'n_tokens_mistral': 716, 'n_tokens_neox': 675, 'n_words': 107, 'path': '.ipynb_checkpoints/datasets-checkpoint.ipynb', 'repo_name': 'ricardo-hdz/aws_cv_gluoncv', 'size': '1991'}