Skip to content

RuntimeError for running tasks/mnist #15

@sIncerass

Description

@sIncerass

There is an

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

issue when I try to run the conv.py/fcn.py code from mnist test example.

Could you please help me with that.

The full log looks like this:

2020-06-08 11:45:37,999 - dni - INFO - __init__: Using DNI to optimize the network
Sequential(
  (0): Conv2d(1, 32, kernel_size=(5, 5), stride=(1, 1), padding=(16, 16))
  (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
 with optimizer adam, lr 0.0001 with Conv2dDNI
2020-06-08 11:45:38,000 - dni - INFO - __init__: Using DNI to optimize the network
Sequential(
  (0): Conv2d(32, 32, kernel_size=(5, 5), stride=(1, 1), padding=(16, 16))
  (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
 with optimizer adam, lr 0.0001 with Conv2dDNI
2020-06-08 11:45:38,001 - dni - INFO - __init__: Using DNI to optimize the network
Sequential(
  (0): Conv2d(32, 32, kernel_size=(5, 5), stride=(1, 1), padding=(16, 16))
  (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
 with optimizer adam, lr 0.0001 with Conv2dDNI
Traceback (most recent call last):
  File "conv.py", line 198, in <module>
    train(epoch)
  File "conv.py", line 164, in train
    loss.backward()
  File "/private/home/shengs/.conda/envs/rand_init/lib/python3.7/site-packages/torch/tensor.py", line 198, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/private/home/shengs/.conda/envs/rand_init/lib/python3.7/site-packages/torch/autograd/__init__.py", line 100, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions