INNER CODE UNIT · Python
trainModel
adminho/trading-stock-thailand · LSTM_predict_trend.py:80
def trainModel(symbolName, Xtrain, Ytrain, Xtest, Ytest, epochs):
history = his.TrainingHistory()
h5_file = os.path.join(MODEL_PATH,'%s_weights.h5' % (symbolName))
json_file = os.path.join(MODEL_PATH,'%s_structure.json' % (symbolName))
global_start_time = time.time()
# Shape: example number, sequence lenght, feature number
model = buildModel(Xtrain.shape, h5_file)
# Learning
#model.fit(Xtrain, Ytrain, batch_size=500, nb_epoch=epochs, verbose=2, validation_split=0.05 )
print('Wait training ... ')
model.fit(Xtrain, Ytrain, batch_size=500,
nb_epoch=epochs,
validation_data=(Xtest, Ytest),
verbose=2,
callbacks=[history])