-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Failed in fine-tuning inception_v3 #302
Comments
Hi @MichaelLiang12, What PyTorch version are you using (found by Thanks |
Also the user warning you are getting when loading the model is fixed in master (via #231) |
Same issue: (tensorflow) wcai@tdtd-desktop ~/tensorflow/AI_competition/pytorch $ python main.py -a inception_v3 . --pretrained Python: Python 3.5.2 print (torch.version) |
Hi @jamiechoi1995, Can you provide a minimum working example of this failing (i.e. an input that causes this when you pass it the model). From the stack trace it seems like the |
You can reproduce this problom by using the code in https://github.com/pytorch/examples/tree/master/imagenet I modify the size of rescale and crop to 299 for inception v3, Using the same code with size of 224 in resnet model is OK, Thanks. |
Isn't this problem because the Aux error branch in the network? If you remove it it should work :) |
@jamiechoi1995 @MichaelLiang12, @TiRune is correct, inception_v3 has an aux branch, and if this is not disabled the forward function will return a tuple (see here), which when passed to the criterion will throw this error. So you have two choices:
output, aux = model(input_var) |
@alykhantejani:Hi, why we have to disable the I'm trying to reproduce the accuracy from a model trained using with the bvlc_googlenet (without pretrained weights). So when I do aux branch off with pytorch(googlenet) it works and reports val_acc with 50% which is very low when compared to the caffe. any other methods to reproduce the same accurcy using pytorch?
|
@rajasekharponakala the
Both googlenet and inception_v3 use pre-trained weights from TensorFlow, and as far as I know we didn't manage to reproduce accuracies from the paper when training from scratch. |
Hi @fmassa, thanks. I followed (pytorch discourse) to add below lines in
but ended with error:
any idea? |
you need to set your model to |
Thanks. Yes, I'm following the example/imagenet/main.py script:
I found some other method in dicourse
This times it throws different error:
|
The issue is that both |
Yeah.
and also vision/models/googlenet.py has
|
@rajasekharponakala one thing to note here is that GoogLeNet has two aux branches where as inception v3 only has one. So for GoogLeNet you have to use: |
@TheCodez: Thanks, its working now!
|
@rajasekharponakala the correct weighting scheme for GoogLeNet is using 0.3: aux1, aux2, output = model(inputs)
loss1 = criterion(outputs, target)
loss2 = criterion(aux1, target)
loss3 = criterion(aux2, target)
loss = loss1 + 0.3 * (loss2 + loss3) |
Yeah, thanks. |
@TheCodez @fmassa @alykhantejani @rajasekharponakala Do we have to set auxiliary classifiers in test mode? I get very poor test accuracy when I retrieve trained model ( auxiliary classifiers are set here). I'm using inception v3 model for my task! |
@tejasri19 for inference, don't forget to set your model to You don't need to use the aux classifiers for inference, only for training |
Hi, i have a question. In the https://github.com/pytorch/vision/blob/master/torchvision/models/googlenet.py if self.training and self.aux_logits:
return _GoogLeNetOutputs(x, aux2, aux1)
return x _GoogLeNetOutputs = namedtuple('GoogLeNetOutputs', ['logits', 'aux_logits2', 'aux_logits1']) so, should it be Is it right? Thanks. |
It should be |
Thanks for this thread it really helped me but now I'm getting this error when unpacking the model output: and even when I added an extra output to unpack: |
I solved it by unpacking the output in seperatelly: |
@gamesMum I would advise not to do that, as you are essentially running your model twice. and then access using:
|
@TheCodez oh dear how did I kiss that! |
|
|
|
@wlj567 see if that works. |
@TheCodez Hello, I don't quite understand how to modify it. Can you have a look?
|
@wlj567 see if that works. loss = self.criterion(outputs.logits, target) |
Do I modify or report an error according to this method |
I modified this part in loss.py and added
Train loss: 4.745: 0%| | 6/5052 [00:12<2:36:10, 1.86s/it] |
Traceback (most recent call last): This is the original code error. |
I failed in using inception_v3 on my own dataset. (Ubuntu14.04, cuda8.0, python3.6.2)
It outputs warning when loaded:
It failed which training:
The text was updated successfully, but these errors were encountered: