I am getting above epoch vs loss plot while training on time series forecasting in keras 2.2.4. Model configuration 1 lstm layer, 1 dense layer, num epochs - 64. On some set of configuration I am getting right plot with just two curves one for validation set and one for training loss dataset while on some configuration I am getting this absurd plot shown in image. I am not able to understand why this is happening? My code --
def train(trainingData, config):
inputShape, numNode, numEpoch, batchSize = config
if nDiff > 0:
trainingData = np.array(difference(trainingData))
trainX, trainY = trainingData[:, :-1], trainingData[:, -1]
trainX = trainX.reshape((trainX.shape[0], trainX.shape[1], 1))
model = Sequential()
model.add(LSTM(numNode, activation = 'relu', input_shape = (inputShape, 1)))
#model.add(Dense(4, activation = 'relu'))
model.add(Dense(1))
model.compile(loss = 'mse' , optimizer = 'adam')
history = model.fit(trainX, trainY, validation_split = 0.2, epochs = numEpoch, batch_size = batchSize, verbose = 0, shuffle = True)
# summarize history for loss
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.savefig(modelName + "ind")
return model