Mapping Tensor from [0, 1] to [-1, +1]

I can’t seem to find an equivalent to Theanos switch() function. Using:

T.switch(inputTensor,1,-1)

where the inputTensor contains binarized information (elements are either 0 or 1) [0, 1] can be mapped to [-1, +1]. I am trying to figure out how to accomplish the same thing in pyTorch using Tensors but none of the functions here: http://pytorch.org/docs/0.3.0/tensors.html seem to have the same ability. Is there anyway to efficiently accomplish this in pyTorch? Any help is greatly appreciated.

Cheers, Corey.

Couldn’t you do x * 2 - 1 ?

1 Like