def train(X_train, y_train):
model = Sequential()
model.add(LSTM(
lstm_neurons,
batch_input_shape=(batch_size, X_train.shape[1], X_train.shape[2]),
stateful=True))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
for i in range(epochs):
print 'batch', i+1
model.fit(
X_train,
y_train,
epochs=1,
batch_size=batch_size,
verbose=2,
shuffle=False,
validation_split=0.33)
model.reset_states()
return model
评论列表
文章目录