szagoruyko/attention-transfer

question about "params.itervalues()"

Closed this issue · 2 comments

(py35) user@user-ASUS:~/fzz/study/attention-transfer-master$ python cifar.py --save logs/resnet_40_1_teacher --depth 40 --width 1
parsed options: {'data_root': '.', 'dataset': 'CIFAR10', 'cuda': False, 'width': 1.0, 'lr': 0.1, 'alpha': 0, 'teacher_id': '', 'gpu_id': '0', 'lr_decay_ratio': 0.2, 'epoch_step': '[60,120,160]', 'beta': 0, 'batchSize': 128, 'ngpu': 1, 'depth': 40, 'randomcrop_pad': 4, 'optim_method': 'SGD', 'nthread': 4, 'weightDecay': 0.0005, 'resume': '', 'epochs': 200, 'save': 'logs/resnet_40_1_teacher', 'temperature': 4, 'dtype': 'float'}
Files already downloaded and verified
Files already downloaded and verified
Traceback (most recent call last):
File "cifar.py", line 331, in
main()
File "cifar.py", line 212, in main
optimizable = [v for v in params.itervalues() if v.requires_grad]
AttributeError: 'collections.OrderedDict' object has no attribute 'itervalues'

When I run 'cifar.py', I got this error, and I can't find the “itervalues” in any file.

Thanks for your update ! I replace the old version with the lasted version, and I find it still has an error:
File "cifar.py", line 266, in log
open(os.path.join(opt.save, 'model.pt7'), 'w'))
File "/home/user/anaconda2/envs/py35/lib/python3.5/site-packages/torch/serialization.py", line 120, in save
return _save(obj, f, pickle_module, pickle_protocol)
File "/home/user/anaconda2/envs/py35/lib/python3.5/site-packages/torch/serialization.py", line 181, in _save
pickle_module.dump(MAGIC_NUMBER, f, protocol=pickle_protocol)
TypeError: write() argument must be str, not bytes

So I find the line 266, and replace the 'w' with 'wb' , now it can works in my environment.

@Fzz123 actually open there was not needed, I removed it via 77055a4, thanks!