SyntaxError in W1C5

Hello, I have an issue similar to the one on Cross Entropy Loss. This is the error message:

  File "<ipython-input-69-f10a7caa0738>", line 20
    loss_layer=tl.CrossEntropyLoss()
                    ^
SyntaxError: invalid syntax

The pointer points at a different place from the previous post. I’ve tried commenting out the line of code above this loss_layer line, but then the SyntaxError moves instead to the optimizer line. Thank you in advance

1 Like

Maybe review what a Python Syntax Error is, and what it implies about the expressions preceding the line where the ^ indicator is placed in the error message.

https://docs.python.org/3/tutorial/errors.html?highlight=syntax%20error

Syntax errors, also known as parsing errors…

There is something fundamentally wrong with what has been typed, such that the parser can’t continue. Look for missing : or , or unbalanced parentheses etc. Notice that until recently, the ^ didn’t point at the location where the error actually happened, but at the subsequent point where the parser failed. (Improved precision in the latest release). HTH

Thank you very much! I realised I had forgotten the comma

1 Like