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?
2 Likes
Can’t you just multiply the output by 10?
3 Likes
This article here: https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/ 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(origOutput.data.numpy())
By the way, according to http://pytorch.org/docs/master/nn.html#torch.nn.LSTM , 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