Multiple outputs from model(input)

Hello,

My apologies upfront if this is a naive question, new to pytorch, coming from keras/lasagne, but I haven’t had much luck searching for answers online so thought I would post here.

There is an implementation of Pytorch here. The model that we are using is cifar_shakeshake26 in architectures.py here.

We have tried to adapt their implementation to our dataset by adding our own model that would accept a 70x70 image. However, when we run, we get this error during validation:

INFO:main:--- training epoch in 13.531290054321289 seconds ---
INFO:main:Evaluating the primary model:
Traceback (most recent call last):
  File "main.py", line 421, in <module>
    main(RunContext(__file__, 0))
  File "main.py", line 103, in main
    prec1 = validate(eval_loader, model, validation_log, global_step, epoch + 1)
  File "main.py", line 331, in validate
    output1, output2 = model(input_var)
ValueError: too many values to unpack (expected 2)

What I don’t understand, is how model(input_var) is returning two variables.

If more information is needed to answer this question, please let me know and i’ll provide it.

Thank you in advance!

-Tommy

Where is the code for model?

From the error it sounds like model(input_var) is returning more than 2 values (or maybe 1 value?). This is possible if the forward function of model returns a tuple.

thanks for the reply. see my edited post.

I’m not too sure what’s going on because the model is intended to return two outputs: https://github.com/CuriousAI/mean-teacher/blob/99cd11f646ec2e4cc6f19836be96a72c55923e00/pytorch/mean_teacher/architectures.py#L161 .

One thing you can do is set a pdb breakpoint there and see if the model output is actually two outputs.

Thank you very much, that pretty much answers my question. Greatly appreciate you taking the time to look at the code : )