Model.eval() in predicting step yields SyntaxError

I adopted a 2-layer neural network in the tutorial:

model = nn.Sequential(
    nn.Linear(D_in, H),
    nn.Tanh(),
    nn.Linear(H, D_out),
)

Then I trained the model, save and load the model in the way as they mentioned here (second answer, case #1). But when the output yields a SyntaxError:

  File "eval01.py", line 63
    model.eval() 
        ^
SyntaxError: invalid syntax

I don’t have any Batchnorm or Dropout layer in my model. Is this the reason of this error?

1 Like

Could you post the code for loading the state dict?
Your error is most likely due to a typo, e.g. a missing parenthesis.

1 Like

Thanks for the hint! It’s indeed a missing parenthesis at the very beginning of the code and the mismatch tracks down to these line. I’m really really sorry :sob:

1 Like

Gosh. Same thing happened to me too :stuck_out_tongue: