1. Why such a big difference between my 'Train loss' and 'Validation loss' as shown in the picture below? Is it a signal that my codes are wrong and my trained network is wrong as well?

enter image description here

  1. Some of my codes are as follows:

timesteps =  5
n_features =  20

epochs = 100
batch = 32
lr = 0.0001

lstm_autoencoder = Sequential([
    # Encoder
    LSTM(8, activation='relu', input_shape=(timesteps, n_features), return_sequences=True),
    LSTM(4, activation='relu', return_sequences=False),

    # Decoder
    LSTM(4, activation='relu', return_sequences=True),
    LSTM(8, activation='relu', return_sequences=True)

adam = optimizers.Adam(lr)
lstm_autoencoder.compile(loss='mse', optimizer=adam)

for stock in stock_list:  # 500 stocks in stock_list
    lstm_autoencoder_history = lstm_autoencoder.fit(X_train_dict[ticker], X_train_dict[ticker], 
                                                    validation_data=(X_valid_dict[ticker], X_valid_dict[ticker]),

plt.plot(lstm_autoencoder_history['loss'], linewidth=2, label='Train')
plt.plot(lstm_autoencoder_history['val_loss'], linewidth=2, label='Valid')
  1. I used the for loop to feed my data into lstm_autoencoder network. In the dictionary variable stock_list, there are 500 stock names such as 'AAPL'.

  2. I plotted lstm_autoencoder_history['loss'] and lstm_autoencoder_history['val_loss'] and it is weird because usually validation loss is higher than train loss.

  3. I am curious to know why my plot has smaller amount of validation loss. For your information, I used Keras as my deep learning framework. And since I used Keras, I thought this library would handle the different proportion of training set size and validation set size by averaging the errors.

  • $\begingroup$ Hi and welcome to this community! Questions that involve implementation issues would better fit Data Science SE, so I would suggest you to ask this question there. $\endgroup$
    – nbro
    Jun 15 '19 at 15:12
  • $\begingroup$ @nbro thank you for your suggestion. I just uploaded my question there as well $\endgroup$
    – Eiffelbear
    Jun 15 '19 at 15:16
  • $\begingroup$ If you receive an acceptable answer there, feel free to delete this version from here. Anyway, please, next time, if you have a question regarding some conceptual, theoretical or philosophical AI problem, feel free to ask it here! $\endgroup$
    – nbro
    Jun 15 '19 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.