New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some doubts #3
Comments
Thank you very much for the kind words!
|
I a newbie, maybe is my code using pytorchmeta non-standard? Could you please use miniimagenet to test the GPU memory usage on protonet which is in your example? I wonder if it is a bug of my own code? thank you! |
I can't see the length of BatchMetaDataLoder, I guess that the arg.num_batches in the example is equal to the num of episode which one episode contains "batchsize" tasks(K-way N-shot) , is right? I also want to know : whether the one iteration of BatchMetaDataLoder is random? If so, can it traverse the entire train_dataset? |
I was indeed able to reproduce the memory issue. This is very likely due to the size of the tensors being stored in memory (
Here is the diff for my test on Prototypical Networks: diff --git a/examples/protonet/model.py b/examples/protonet/model.py
index 8d64a83..a4ce1e6 100644
--- a/examples/protonet/model.py
+++ b/examples/protonet/model.py
@@ -24,4 +24,5 @@ class PrototypicalNetwork(nn.Module):
def forward(self, inputs):
embeddings = self.encoder(inputs.view(-1, *inputs.shape[2:]))
+ embeddings = embeddings.mean([2, 3])
return embeddings.view(*inputs.shape[:2], -1)
diff --git a/examples/protonet/train.py b/examples/protonet/train.py
index 1f89913..8cc7cd3 100644
--- a/examples/protonet/train.py
+++ b/examples/protonet/train.py
@@ -2,19 +2,20 @@ import os
import torch
from tqdm import tqdm
-from torchmeta.datasets.helpers import omniglot
+from torchmeta.datasets.helpers import omniglot, miniimagenet
from torchmeta.utils.data import BatchMetaDataLoader
from model import PrototypicalNetwork
from utils import get_prototypes, prototypical_loss, get_accuracy
def train(args):
- dataset = omniglot(args.folder, shots=args.num_shots, ways=args.num_ways,
- shuffle=True, test_shots=15, meta_train=True, download=args.download)
+ dataset = miniimagenet(args.folder, shots=args.num_shots, ways=args.num_ways,
+ shuffle=True, test_shots=None, meta_train=True,
+ download=args.download)
dataloader = BatchMetaDataLoader(dataset, batch_size=args.batch_size,
shuffle=True, num_workers=args.num_workers)
- model = PrototypicalNetwork(1, args.embedding_size,
+ model = PrototypicalNetwork(3, args.embedding_size,
hidden_size=args.hidden_size)
model.to(device=args.device)
model.train() Regarding your second question you are right: in the protonet example, |
I have to admit that I really appreciate this project, i think if you want to enable seamless and consistent evaluation of meta-learning algorithms , you should verify availability of Torchmeta. You should show the results or examples of different algorithms to us to make a fair comparison. I test Torchmeta on miniImagenet use your provided protonet example, the obtained results are much higher than value provided in the origial paper, so I was amazed. I will continue to care about this project, we are looking forward to your comprehensive experimental verification! |
Thank you! Having the results for the examples in the repo would be great, I will definitely try to have them available. |
Hi, I really appreciate your great work ! But i have some doubts about details.
Looking forward to your reply, thank you!
The text was updated successfully, but these errors were encountered: