Пример #1
0
            + '.png',
            dpi=700)
    elif mode == 2:
        plt.savefig(
            '/home/vacek/Cloud/cloud-predictor/GoogleClusterTaskEvents/v2/Prediction-cs-100/LSTM-convnet/results/Normalized_RAM_Train_Loss'
            + '.png',
            dpi=700)
    plt.pause(3)
    plt.close()
    ''' saving the trained model'''
    if mode == 1:
        model.save('model-CPU.h5')  # creates a HDF5 file
    elif mode == 2:
        model.save('model-RAM.h5')  # creates a HDF5 file

    predicted = Train_LSTM.predict_point_by_point(model, X_test)
    y_test = np.reshape(y_test, (y_test.size, ))
    print(len(predicted), len(y_test), '------------')

    del X_train, X_test
    print('-----\n--------------\n--------------------------')
    sleep(3)

    print('Training duration (s) : ', time.time() - global_start_time)

    print(' --------------------------------- ')
    from sklearn.metrics import mean_squared_error
    from math import sqrt

    rms = sqrt(mean_squared_error(y_test, predicted))
    ms = mean_squared_error(y_test, predicted)
Пример #2
0
        import matplotlib.pyplot as plt

        loss = history.history['loss']
        val_loss = history.history['val_loss']
        epochs = range(1, len(loss) + 1)
        plt.figure()
        plt.plot(epochs, loss, 'bo', label='Training loss')
        plt.plot(epochs, val_loss, 'b', color='red', label='Validation loss')
        plt.title('Training and validation loss')
        plt.legend()
        plt.pause(3)
        plt.close()

        # predictions = lstm.predict_sequences_multiple(model, X_test, seq_len, 50)
        predicted = Train_LSTM.predict_point_by_point(model, X_test)
        print(len(predicted), '------------')

        # note that we can predict point by point each step using last true data!!!
        predicted2 = []
        for ii in range((X_test.shape[0])):
            if ii > 1:
                tmp = X_test[ii, :, :]
                tmp[-1, :] = y_test[ii - 1]
                input_seq = np.reshape(tmp, (1, tmp.shape[0], tmp.shape[1]))
            else:
                input_seq = np.reshape(
                    X_test[ii, :, :],
                    (1, X_test[ii, :, :].shape[0], X_test[ii, :, :].shape[1]))
            # print(input_seq.shape)
            y = Train_LSTM.predict_point_by_point(model, input_seq)