RuntimeError: Function 'MulBackward0' returned nan values in its 0th output

i did what you just said and i have this


RuntimeError Traceback (most recent call last)
in
1 spiking_model = SpikingNet(device, n_time_steps=1200, begin_eval=0)
----> 2 train_many_epochs(spiking_model)

in train_many_epochs(model)
27 epoch = i
28 optimizer = optim.SGD(model.parameters(), lr=0.1, momentum=0.5)
—> 29 train(model, device, train_set_loader, optimizer, epoch, logging_interval=1)
30 test(model, device, test_set_loader)
31

in train(model, device, train_set_loader, optimizer, epoch, logging_interval)
10 target = target.long()
11 loss = F.nll_loss(output, target)
—> 12 loss.backward()
13
14 torch.nn.utils.clip_grad_norm_(model.parameters(),0.5)

~.conda\envs\py36\lib\site-packages\torch\tensor.py in backward(self, gradient, retain_graph, create_graph)
193 products. Defaults to False.
194 “”"
–> 195 torch.autograd.backward(self, gradient, retain_graph, create_graph)
196
197 def register_hook(self, hook):

~.conda\envs\py36\lib\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: Function ‘MulBackward0’ returned nan values in its 0th output.

still nothing leading to the forward function
i have also checked the output of the forward function and couldn’t find nans (i might have missed it tho)