You are passing x that is None to test as the second argument. The train function doesn’t have an explicit return statement so it returns None. Just return the model in train to remove the error. Additionally, you can decorate the test function with torch.no_grad() to speed up the inference and call net.eval() to set the model in evaluation mode.