Inverting MNIST Dataset

I am trying to make a negative-image version of MNIST dataset for training a CNN.
This is what I did so far:

train_mnist = datasets.KMNIST('data', download=True, train=True, transform=transform_mnist)
inv = 1 - train_mnist.data  

trainloader = DataLoader(inv , batch_size=64, shuffle=True)

dataiter = iter(trainloader)
images, labels = dataiter.next()

figure = plt.figure()
num_of_images = 60
for index in range(1, num_of_images + 1):
    plt.subplot(6, 10, index)
    plt.axis('off')
    plt.imshow(images[index].numpy().squeeze(), cmap='gray_r')

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-35-f7d1c6cd96f7> in <module>
      6 
      7 dataiter = iter(trainloader)
----> 8 images, labels = dataiter.next()
      9 
     10 figure = plt.figure()

ValueError: too many values to unpack (expected 2)

Appreciate any suggestions on how to fix it. I do realize that I can’t just do (1 - data) since it will also change the target values.

I am not sure if your code is correct; but, a better alternative is to pass the invert function within the transform:
PIL.ImageOps. invert ( image )
Here is a link to PIL invert.