katerakelly/pytorch-maml

errors when loading weights

kailigo opened this issue · 0 comments

Thanks for the code. I meet the following problem when trying to run your code. I used pytorch 0.2.0, python 3.5.

tee: ../logs/maml-omniglot-5way-1shot-TEST: No such file or directory
exp maml-omniglot-5way-1shot-TEST
dataset omniglot
num_cls 5
num_inst 1
batch 1
m_batch 32
num_updates 15000
num_inner_updates 5
lr 1e-1
meta_lr 1e-3
gpu 0
Setting GPU to 0
init weights
init weights
init weights
> /zdata/users/kaili/code/pytorch-maml/src/maml.py(102)test()
-> for _ in range(10):
(Pdb) c
-------------------------
Meta train: 0.1178786426782608 1.0
Meta val: 1.139253568649292 0.7
-------------------------
inner step 0
inner step 1
Traceback (most recent call last):
  File "maml.py", line 234, in <module>
    main()
  File "/home/mli/kaili/anaconda2/envs/kai_py35_torch02/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/mli/kaili/anaconda2/envs/kai_py35_torch02/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/mli/kaili/anaconda2/envs/kai_py35_torch02/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mli/kaili/anaconda2/envs/kai_py35_torch02/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "maml.py", line 231, in main
    learner.train(exp)
  File "maml.py", line 166, in train
    metrics, g = self.fast_net.forward(task)
  File "/zdata/users/kaili/code/pytorch-maml/src/inner_loop.py", line 61, in forward
    loss, _ = self.forward_pass(in_, target, fast_weights)
  File "/zdata/users/kaili/code/pytorch-maml/src/inner_loop.py", line 43, in forward_pass
    out = self.net_forward(input_var, weights)
  File "/zdata/users/kaili/code/pytorch-maml/src/inner_loop.py", line 36, in net_forward
    return super(InnerLoop, self).forward(x, weights)
  File "/zdata/users/kaili/code/pytorch-maml/src/omniglot_net.py", line 49, in forward
    x = batchnorm(x, weight = weights['features.bn1.weight'], bias = weights['features.bn1.bias'], momentum=1)
  File "/zdata/users/kaili/code/pytorch-maml/src/layers.py", line 31, in batchnorm
    running_mean = torch.zeros(np.prod(np.array(input.data.size()[1]))).cuda()
TypeError: torch.zeros received an invalid combination of arguments - got (numpy.int64), but expected one of:
 * (int ... size)
      didn't match because some of the arguments have invalid types: (!numpy.int64!)
 * (torch.Size size)
      didn't match because some of the arguments have invalid types: (!numpy.int64!)

Any clue to solve this? Thanks.