I copied an error from a test… I was just trying something out… My mistake. Here is the error:

Epoch:   0%|          | 0/4 [00:00<?, ?it/s]
RuntimeError                              Traceback (most recent call last)
 in 
29     train_loss_set.append(loss.item())
30     # Backward pass
—> 31     loss.backward()
32     # Update parameters and take a step using the computed gradient
33     optimizer.step()
/opt/conda/lib/python3.7/site-packages/torch/tensor.py in backward(self, gradient, retain_graph, create_graph)
219                 retain_graph=retain_graph,
220                 create_graph=create_graph)
 → 221         torch.autograd.backward(self, gradient, retain_graph, create_graph)
222
223     def register_hook(self, hook):
/opt/conda/lib/python3.7/site-packages/torch/autograd/init.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
130     Variable.execution_engine.run_backward(
131         tensors, grad_tensors, retain_graph, create_graph,
 → 132         allow_unreachable=True)  # allow_unreachable flag
133
134
RuntimeError: Found dtype Double but expected Float