learnables / learn2learn

A PyTorch Library for Meta-learning Research
http://learn2learn.net
MIT License
2.63k stars 351 forks source link

Reptile example issue #132

Closed joey-wang123 closed 3 years ago

joey-wang123 commented 4 years ago

Dear authors,

    Thank you for your fantastic projects and contributions! I currently use your code base for reptile experiment for miniimagenet. I run the script reptile_miniimagenet.py and got the following errors. 

RuntimeError: Expected 4-dimensional input for 4-dimensional weight 32 3 3, but got 3-dimensional input of size [10, 84, 84] instead

After that, I change the original code of.

data = random.sample(adaptation_data, batch_size) adapt_X = torch.cat([d[0].unsqueeze(0) for d in data], dim=0).to(device) adapt_y = torch.cat([torch.tensor(d[1]).view(-1) for d in data], dim=0).to(device) opt.zero_grad() error = loss(learner(adapt_X), adapt_y)

To the following, similar to the script in MAML miniimagenet:

error = loss(learner(adaptation_data), adaptation_labels)

But the performance is worse, close to 40%, could you tell me how to get the similar results in the reptile paper? Thank you!

seba-1511 commented 4 years ago

Hello @joey-wang123,

Thank you for catching the issue with the batch shape.

Regarding the convergence error, I didn't have time to check. As far as I remember, the implementation is correct so it might be an issue with the default hyper-parameters. I found Reptile to be quite sensitive to their values.

I'll try to get back to this issue, but my bandwidth will be limited for the next few weeks.

seba-1511 commented 4 years ago

Hi @joey-wang123 ,

I can finally confirm that the uploaded reptile example is an older version which does not replicate published results. I'll create a PR to fix that. In the meantime, you can have a look at this gist to get an idea of what the changes will look like.

Thanks again for reporting this.

joey-wang123 commented 4 years ago

Many thanks for your reply!

Séb Arnold notifications@github.com 于2020年5月15日周五 下午3:39写道:

Hi @joey-wang123 https://github.com/joey-wang123 ,

I can finally confirm that the uploaded reptile example is an older version which does not replicate published results. I'll create a PR to fix that. In the meantime, you can have a look at this gist https://gist.github.com/seba-1511/30e08ff2e680769dc06bc6da81cd33e7 to get an idea of what the changes will look like.

Thanks again for reporting this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/learnables/learn2learn/issues/132#issuecomment-629439976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO52GU3N52PIPFL5MLQRBMLRRWK5PANCNFSM4LTCWNXQ .

steremma commented 3 years ago

Any update on this?

seba-1511 commented 3 years ago

Thanks for the reminder @steremma! The new version is merged in #225 :)