Unterhalb der RNN ist, dass ich Keras bauen mit:RNN Verlust wird NaN aufgrund der sehr großen Vorhersagewerte
def RNN_keras(feat_num, timestep_num=100):
model = Sequential()
model.add(BatchNormalization(input_shape=(timestep_num, feat_num)))
model.add(LSTM(input_shape=(timestep_num, feat_num), output_dim=512, activation='relu', return_sequences=True))
model.add(BatchNormalization())
model.add(LSTM(output_dim=128, activation='relu', return_sequences=True))
model.add(BatchNormalization())
model.add(TimeDistributed(Dense(output_dim=1, activation='linear'))) # sequence labeling
rmsprop = RMSprop(lr=0.00001, rho=0.9, epsilon=1e-08)
model.compile(loss='mean_squared_error',
optimizer=rmsprop,
metrics=['mean_squared_error'])
return model
Die Ausgabe ist wie folgt:
61267 in the training set
6808 in the test set
Building training input vectors ...
888 unique feature names
The length of each vector will be 888
Using TensorFlow backend.
Build model...
****** Iterating over each batch of the training data ******
# Each batch has 1280 examples
# The training data are shuffled at the beginning of each epoch.
Epoch 1/3 : Batch 1/48 | loss = 607.043823 | root_mean_squared_error = 24.638334
Epoch 1/3 : Batch 2/48 | loss = 14479824582732.208323 | root_mean_squared_error = 3805236.468701
Epoch 1/3 : Batch 3/48 | loss = nan | root_mean_squared_error = nan
Epoch 1/3 : Batch 4/48 | loss = nan | root_mean_squared_error = nan
Epoch 1/3 : Batch 5/48 | loss = nan | root_mean_squared_error = nan
......
Der Verlust geht sehr hoch in die zweite Charge und wird dann nan. Das wahre Ergebnis y enthält keine sehr großen Werte. Die maximale y ist kleiner als 400.
Auf der anderen Seite, ich überprüfe die Vorhersage Ausgabe y_hat. Die RNN gibt eine sehr hohe Vorhersage zurück, die zu unendlich führt.
Allerdings bin ich immer noch verwirrt, wie man mein Modell verbessert.
hast du versucht, den Entropieverlust zu wechseln – Julius
hast du 'tanh' oder' sigmoid' anstelle von 'relu' versucht, um große Werte zu vermeiden? –
@Julius Dies ist ein Regressionsproblem. Ist der Entropieverlust auch anwendbar? – Munichong