I get a cuda error if I do that 


RuntimeError                              Traceback (most recent call last)
 in 
23
24         # Getting gradients w.r.t. parameters
—> 25         loss.backward()
26
27         # Updating parameters
~/anaconda3/lib/python3.7/site-packages/torch/tensor.py in backward(self, gradient, retain_graph, create_graph)
164                 products. Defaults to False.
165         “”"
–> 166         torch.autograd.backward(self, gradient, retain_graph, create_graph)
167
168     def register_hook(self, hook):
~/anaconda3/lib/python3.7/site-packages/torch/autograd/init.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
97     Variable._execution_engine.run_backward(
98         tensors, grad_tensors, retain_graph, create_graph,
—> 99         allow_unreachable=True)  # allow_unreachable flag
100
101
RuntimeError: CUDA error: device-side assert triggered

Also I’m giving my input dimensions as such:
input_dim = 28*28*3
output_dim = 2
model = FeedForward_NN(input_dim,output_dim)