LSTM Output Output Range

Currently the LSTM default output using nn.LSTM() is [0, 1] , from 0 to 1, due to the sigmoid output, how do I increase to say [0, 10], from 0 to 10?


Can’t you just multiply the output by 10?


This article here: has a more automatic way of doing this using scikit-learn’s scalers (I haven’t tested the following code as is though):

from sklearn.preprocessing import MinMaxScaler

# build a transformation to have the transformation result in the range 0..1
scaler = MinMaxScaler(feature_range=(0, 1)) 

# apply the transformation to the target values (note that fit_transform() 
# expects a 2D tensor)
transformedTarget = scaler.fit_transform(target)

# perform training

# apply inverse transform
origOutput = network.forward(...)
output = scaler.inverse_transform(

By the way, according to , h(t) (which is taken as the cell’s output) is a product of a sigmoid and a tanh, so in the range -1…1 .

1 Like