Hi, I've been trying to use IVON for a MDE task, but I get the following error which leaves me kinda clueless:
Traceback (most recent call last):
File "/p/project1/.../src/mde.py", line 205, in <module>
main(args)
File "/p/project1/.../src/mde.py", line 182, in main
train_loss = train(model, optim, train_dataloader)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/project1/.../src/mde.py", line 87, in train
return _train_epoch_ivon(model, optim, dataloader, n_samples)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/project1/.../src/mde.py", line 69, in _train_epoch_ivon
with optim.sampled_params(train=True):
File "/p/software/jurecadc/stages/2024/software/Python/3.11.3-GCCcore-12.3.0/lib/python3.11/contextlib.py", line 144, in __exit__
next(self.gen)
File "/p/project1/.../venv/lib/python3.11/site-packages/ivon/_ivon.py", line 132, in sampled_params
self._restore_param_average(train, param_avg, noise)
File "/p/project1/.../venv/lib/python3.11/site-packages/ivon/_ivon.py", line 149, in _restore_param_average
param_grads.append(p.grad.flatten())
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'flatten'
the corresponding calling code snippet is this one:
64 def _train_epoch_ivon(model, optim, dataloader, n_samples=1):
65 train_loss = 0
66
67 for x, y in tqdm(dataloader):
68 for _ in range(n_samples):
69 with optim.sampled_params(train=True):
70 optim.zero_grad()
71 x = x.to(device)
72 y = y.to(device)
73
74 ypred = predict(model, x, y.shape)
75 loss = F.l1_loss(normalize(ypred), normalize(y))
76
77 train_loss += loss.item()
78
79 loss.backward()
80
81 optim.step()
82
83 return train_loss / len(dataloader)
Is there any obvious mistake I'm overlooking? n_samples is set to 1.
Btw, this is running on Python 3.11, PyTorch 2.1.2 and ivon-opt 0.1.3.
Thanks in advance for any help! :)
Hi, I've been trying to use IVON for a MDE task, but I get the following error which leaves me kinda clueless:
the corresponding calling code snippet is this one:
Is there any obvious mistake I'm overlooking?
n_samplesis set to 1.Btw, this is running on Python 3.11, PyTorch 2.1.2 and ivon-opt 0.1.3.
Thanks in advance for any help! :)