classify labels to -1 or 1
I have a tensor with values between -1 and 1 . How can I get a new tensor such that where were negative values now there will be one and where were positive numbers now there will be 1? (efficiently)
Namely,
tensor1 = [-0.1, 0.5, 0.08]
new_tensor = [-1, 1, 1]

and zero will be -1 or 1

With numpy it is trivial:
import numpy as np
tensor1 = [-0.1, 0.5, 0.08]
new_tensor = np.sign(tensor1)
new_tensor[new_tensor==0] = 1

