Demo entry 6780212

фывфывфывфывфвыф

   

Submitted by anonymous on Dec 23, 2018 at 17:14
Language: Python. Code size: 705 Bytes.

def train_lstm(train, batch_size, nb_epoch, neurons):
	X, y = train[:, 0:-1], train[:, -1]
	X = X.reshape(X.shape[0], 1, X.shape[1])
    #создание модели
	model = Sequential()
    #добавление в модель LSTM сети
	model.add(LSTM(neurons, batch_input_shape=(batch_size, X.shape[1], X.shape[2]), stateful=True))
    #добавление в модель слоя c 1 выходным нейроном
	model.add(Dense(1))
    #loss-функция ошибки, optimizer- используемый оптимизатор задающий параметры обучения
	model.compile(loss='mean_squared_error', optimizer='adam')
    #цикл обучения
	for i in range(nb_epoch):
		model.fit(X, y, epochs=1, batch_size=batch_size, verbose=0, shuffle=False)
		model.reset_states()
	return model

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).