我正在使用keras LSTM层,并且我的输出预测彼此非常相似。它们相差不超过2个单位。这是我的代码:
model = Sequential()
model.add(LSTM(5, activation='relu', input_dim=5))
model.add(Dense(units=1, activation='sigmoid'))
model.compile(loss='mean_squared_error',
optimizer='sgd',
metrics=['accuracy'])
prediction = model.predict(x_scaled_test, batch_size=128)
Gold_prices = prediction*(max(Input['Gold Price']) - min(Input['Gold Price'])) + min(Input['Gold Price'])
print(Gold_prices)
我的输出是:
[[ 1288.44628906]
[ 1289.5736084 ]
[ 1289.57202148]
[ 1287.84240723]
[ 1287.92114258]
[ 1287.15515137]
[ 1287.58068848]
[ 1287.59069824]
[ 1287.55432129]
[ 1286.953125 ]
[ 1286.72021484]
[ 1285.88684082]
[ 1285.25085449]
[ 1285.2557373 ]
[ 1285.06494141]
[ 1285.65588379]
[ 1285.36767578]
[ 1285.87121582]
[ 1286.1427002 ]
[ 1286.52526855]
...
我正在使用relu和Sigmoid函数作为激活函数。
答案 0 :(得分:1)
根据this issue,您可以尝试以下操作:
答案 1 :(得分:0)
如果您正在使用Resression,则应在输出层上使用线性激活
model = Sequential()
model.add(LSTM(5, activation='relu', input_dim=5))
model.add(Dense(units=1, activation='linear'))