Skip to content

Instantly share code, notes, and snippets.

@andrewm4894
Created January 23, 2019 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewm4894/48fa72cf730eead43f3ce54cdb3842cb to your computer and use it in GitHub Desktop.
Save andrewm4894/48fa72cf730eead43f3ce54cdb3842cb to your computer and use it in GitHub Desktop.
# build network
model = Sequential()
# add number of layer specified
for layer in range(N_LAYERS):
model.add(LSTM(N_LSTM_UNITS,input_shape=(N_TIMESTEPS,N_FEATURES),return_sequences=True))
model.add(Dense(N_FEATURES))
model.compile(loss='mae', optimizer='adam')
# print model summary
print(model.summary())
# reshape data for training
print(f'... reshaping data for training ...')
data_train = data_reshape_for_model(data,N_TIMESTEPS,N_FEATURES)
# begin training iterations
for i in range(N_TRAIN_ITERATIONS):
print(f'... training iteration {i} ...')
model = train(model,data_train,callbacks=[LossHistory()])
# get predictions on healthy data using final trained model
yhat = predict(model,data_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment