MXNet Forum transforms throws AssertionError


I’ve implemented a image classification model that trains well. I have then moved onto doing image augmentation at training time via package a la

transform_train = transforms.Compose([
# Randomly flip the image horizontally
# Randomly flip the image horizontally
# Randomly jitter the brightness, contrast and saturation of the image
transforms.RandomColorJitter(brightness=0.1, contrast=0.1, saturation=0.1),
# Randomly adding noise to the image

train_data =, train_Y)
train_iter =,
BATCHSIZE, shuffle=True)

When calling
for i (data, label) in enumerate(train_iter):

I get the following error

AssertionError: HybridBlock requires the first argument to forward be either Symbol or NDArray, but got <class ‘numpy.ndarray’>

Any idea how to fix this?


The problem is that your inputs (train_X, train_Y) are numpy arrays. You need to convert them to mx.nd.arrays. The following should work: train_data =, mx.nd.array(train_Y))