SyntaxError: invalid character in identifier - Pytorch 1.3.1
When executing the following method:

def flatten(t):
    t = t.reshape(1, −1)
    t = t.squeeze()
    return t


Python complains about the second argument.

  File "pytorch.py", line 16
t = t.reshape(1, −1)
                  ^       SyntaxError: invalid character in identifier


My pytorch version is 1.3.1.
I already tried to remove the space before the argument with no effect. Any ideas?

The character in −1 is not a hyphen. Rather it's the actual minus sign from unicode.
This makes the python interpreter think that −1 is an identifier instead of -1 value.

You might have copied the code from somewhere that has this stylised characters. Just replace − with -
