Open philtomson opened 5 years ago
debugging this a bit, it calls utils.detatch() and ends up at:
-> return tuple(detach(v) for v in h)
/home/phil/devel/ENAS-pytorch/utils.py(131)detach()
-> return tuple(detach(v) for v in h)
> /home/phil/.virtualenvs/p3.6/lib/python3.6/site-packages/torch/tensor.py(380)__iter__()
-> if self.dim() == 0:
(Pdb) pp self
tensor(0.2035, device='cuda:0', grad_fn=<SelectBackward>)
(Pdb) p self.dim()
0
So since it's a scalar and the dim is 0 it's going to raise a type error:
(Pdb) ll
373 def __iter__(self):
374 # NB: we use 'imap' and not 'map' here, so that in Python 2 we get a
375 # generator and don't eagerly perform all the indexes. This could
376 # save us work, and also helps keep trace ordering deterministic
377 # (e.g., if you zip(*hiddens), the eager map will force all the
378 # indexes of hiddens[0] before hiddens[1], while the generator
379 # map will interleave them.)
380 -> if self.dim() == 0:
381 raise TypeError('iteration over a 0-d tensor')
If I'm understanding the response to this issue: https://github.com/carpedm20/ENAS-pytorch/issues/22 PyTorch 0.4.1 is not supported (needs to be 0.3.1?)
Just an FYI for folks wanting to run this code under versions of Pytorch >= 0.4.0: In trainer.py you should not use the call to utils.detach() - instead you should call detach_() on hidden:
Change from:
hidden = utils.detach(hidden)
to:
hidden.detach_()
I resolved this error by changing that function in lstm_rnn fastai file Before def repackage_var(h): return Variable(h.data) if type(h) == Variable else tuple(repackage_var(v) for v in h) After def repackage_var(h): if not isinstance(h, list) and not isinstance(h, tuple) and len(h.size())==0: h = torch.tensor([[h.data]]) return Variable(h.data) if type(h) == Variable else tuple(repackage_var(v) for v in h)
I tried running:
python main.py --network_type rnn --dataset ptb --controller_optim adam --controller_lr 0.00035 --shared_optim sgd --shared_lr 20.0 --entropy_coeff 0.0001
But got:
Running Pytorch 0.4.1 on Python 3.7 (also tried on python 3.6.6, pytorch 0.4.1 and had same issue)