I'm trying to run a python code. This code have an '@' ( at) operator. I never saw it before, and Google returns no hits.
init = model.potentials[key].init_weights(model)
if init.ndim==2:
U, S, Vt = np.linalg.svd(init, False)
init = U@Vt
It says the following error:
init = U@Vt
^
SyntaxError: invalid syntax
I'm using Python 2.7 to compile it. Do anyone know about this operator ?
The @
operator was proposed in PEP 465 and adopted into Python 3.5. You can't use it because you are using an older branch of Python. It is used to multiply matrixes (usually, but you can actually make @
do anything). You can use numpy.dot()
instead if you are working with NumPy arrays, like this:
init = model.potentials[key].init_weights(model)
if init.ndim==2:
U, S, Vt = np.linalg.svd(init, False)
init = np.dot(U, Vt)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With