Fitting the MNIST dataset to neural network giving “NotImplementedError”

I’m new to PyTorch and I’m using the MNIST dataset for image classification as in Chapter 8.While fitting the model, I’m getting the error :

NotImplementedError: uint8

The code I’m using is as follows :

from keras.datasets import mnist
import matplotlib.pyplot as plt
from fastai.metrics import *
from fastai.model import *
from fastai.dataset import *
import torch.nn as nn

(x_train, y_train), (x_valid, y_valid) = mnist.load_data()

net = nn.Sequential(
  nn.Linear(784,10),
  nn.Softmax()).cuda()

md = ImageClassifierData.from_arrays('/data/mnist', 
(x_train,y_train), 
(x_valid, y_valid))   

loss = nn.NLLLoss()
metrics = [accuracy]
opt=optim.SGD(net.parameters(), 1e-1, momentum=0.9, weight_decay=1e-3)

fit(net, md, n_epochs=3, crit=loss, opt=opt, metrics=metrics)

I have spent awful amount of time figuring this out but sadly I couldn’t. Can someone tell what is this error about and it’s solution?