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
Adapting to Different Image Size #7
Comments
Hi, The implementation contains two different architectures: The architectures are defined in pytorch/mean_teacher/architectures.py and can be applied with the
See the experiments/imagenet_valid.py for a more complete set of good hyperparams. If I recall correctly, the resnext152 architecture works with image sizes equal to or larger than 224x224. One way to tweak it to work with different image sizes is to change the first convolutional layer here to something that suits your need. You may also want to adapt the number of layers here at first, since the 152-layer one may take days or weeks to train. Alternatively, you can add your own architectures in the architectures.py. It should also be fairly easy to plug in architectures from torchvision.models. I hope this helps. |
Thank you very much for the quick reply. I tried to add in other models. I am getting an error:
For more information, one of our classification problems involves images which are 70x70 for which there are 10 classes. For the other, the images are 224x224 and it is a binary classification problem. So, with this example, the mean-teacher implementation errors out when it attempts to calculate the Prec@5, which is understandable. But, I don't understand why there are the two variables expected to be returned for model(input_var) and why changing the model architecture causes it to fail? |
Whoops, I think you stepped on a bug. Thanks for letting me know! The code was meant to support cases where the model returns either one or two outputs. This is done on lines 225-235 of the I'm not on my development machine, so I cannot fix it today. A quick fix for your case may be e.g. to change
to
on lines 327-328 of the Two outputs are needed when |
Thank you very much for the reply again. Thank you for being so responsive. It's looks like a great implementation and we are having fun playing with it. Since it sounds like you are still interested in actively maintaining it, I thought I would pass along another thing I ran into in case you are interested. One of our classification problems is a 224x224 image that is either positive or negative. So, when I put that dataset into resnext152, I get:
Which looks like it is complaining about there not being 5 classes. So, not an issue, but just wanted to pass it along since your response felt like you were still working on this. You might feel this needed handling, but may not be necessary for your use-case. But, just in case! : ) Thank you again for your help so far, |
TyoeError:softmax() get an unexpected keyword argument 'dim' |
Thank you for the awesome implementation. I have been trying to use it for a binary classification task. However, I have come across something I find strange. It appears that the softmax1 or softmax2 are not actually used. softmax1, softmax2 = F.softmax(output1, dim=1), F.softmax(output2, dim=1) Should output1 in fact be softmax1? I am curious because it appears we are putting the raw logits class criterion instead of the softmax. Is this correct? |
Hi Johnny, Yeah, the first line is superfluous. I must have been using the softmaxes for debugging or something else and then forgotten them there. Thanks for pointing it out. The class_criterion is actually a CrossEntropyLoss which takes logits as inputs. So the second line is correct. |
Great, that makes sense. Thank you for the quick reply! Again I appreciate the great implementation. |
Hello,
Our team is interested in testing an implementation of the mean-teacher Resnet in PyTorch for a few image classification problems we are working on.
However, we are having difficulty adapting the network to our image dimensions.
If I resize our images to 32x32 it runs without error. But, if I change to something else, I get:
Which makes sense. We're just a little unfamiliar with PyTorch and, speaking for myself, Resnet. So, I thought I would post this question while I was looking into this to see if someone might post an obvious hint that may not be obvious to find.
Thank you in advance,
Tommy
The text was updated successfully, but these errors were encountered: