Exemple #1
0
    h, mdl = training(mdl, 0.0001, X_train, y_train)
    hist.append(h)

    time.append(timeit.default_timer())

    h, mdl = training(mdl, 0.00001, X_train, y_train)
    hist.append(h)

    time.append(timeit.default_timer())

    h, mdl = training(mdl, 0.000001, X_train, y_train)
    hist.append(h)

    time.append(timeit.default_timer())

    mdl.save('final_model')

#%% Plotting history of training
hist_acc = []
hist_loss = []
for h in hist:
    hist_acc.append(h.history['accuracy'])
    hist_loss.append(h.history['loss'])
hist_acc = np.hstack(hist_acc)
hist_loss = np.hstack(hist_loss)
plt.figure()
plt.plot(hist_acc)
plt.legend(['train', 'val'])
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.figure()
Exemple #2
0
                          batch_size=10,
                          validation_data=({
                              'model_input': x_test
                          }, {
                              'd_output': x_test,
                              'p_output': y_test
                          }))

encoder = Model(main_input, encoded, name="encoder")
decoded_input = Input(shape=(4, ))
decoded_p = full_model.get_layer('d1')(decoded_input)
decoded_p = full_model.get_layer('d2')(decoded_p)
decoded_p = full_model.get_layer('d_output')(decoded_p)
decoder = Model(decoded_input, decoded_p)
regression = Model(main_input, regression)
encoded_res = encoder.predict(x_test)
decoded_res = decoder.predict(encoded_res)
regression_res = regression.predict(x_test)

decoder.save('decoder.h5')
encoder.save('encoder.h5')
regression.save('regression.h5')

pd.DataFrame(np.round(x_test, 5)).to_csv("x_test.csv")
pd.DataFrame(np.round(y_test, 5)).to_csv("y_test.csv")
pd.DataFrame(np.round(x_train, 5)).to_csv("x_train.csv")
pd.DataFrame(np.round(y_train, 5)).to_csv("y_train.csv")

pd.DataFrame(np.round(encoded_res, 5)).to_csv("encoded_res.csv")
pd.DataFrame(np.round(decoded_res, 5)).to_csv("decoded_res.csv")
pd.DataFrame(np.round(regression_res, 5)).to_csv("regression_res.csv")