Esempio n. 1
0
def Experiment3():

    mini_batch = 64
    keep_prob = 0.5
    # create model
    model = Neuralnet()
    model.add_layer(512, 1024, keep_prob=keep_prob, activation="sigmoid")
    model.add_layer(64, keep_prob=keep_prob, activation="sigmoid")
    model.add_layer(Y.shape[1], keep_prob=keep_prob, activation="no")

    # Compile model
    no_iterations = 1
    learning_rate = 0.001
    print("Learning-Rate:- ", learning_rate, " Batch_Size:- ", mini_batch)

    losses, te_losses, out = model.train(training_f_X,
                                         training_f_Y,
                                         test_X,
                                         test_Y,
                                         learning_rate,
                                         mini_batch,
                                         no_iterations,
                                         dropout=True)
    title = "Exp3:- Batch size=" + str(mini_batch) + " Learning Rate=" + str(
        learning_rate) + " with dropout"
    plots.linear_plot([x for x in range(len(losses))], losses, te_losses,
                      "Iterations", "Losses", title, 5)
    plt.savefig("../" + title + ".png")
    np.savetxt("../3-64.csv", np.array(out), delimiter="|")
Esempio n. 2
0
def adam():

    mini_batch = 64
    keep_prob = 1
    # create model
    model = Neuralnet()
    model.add_layer(512, 1024, keep_prob=keep_prob, activation="sigmoid")
    model.add_layer(64, keep_prob=keep_prob, activation="sigmoid")
    model.add_layer(Y.shape[1], keep_prob=keep_prob, activation="no")

    # Compile model
    no_iterations = 100
    learning_rate = 0.01
    print("Learning-Rate:- ", learning_rate, " Batch_Size:- ", mini_batch)

    losses, te_losses, out = model.train(training_f_X,
                                         training_f_Y,
                                         test_X,
                                         test_Y,
                                         learning_rate,
                                         mini_batch,
                                         no_iterations,
                                         opt="adam")
    title = "Adam:- Batch size=" + str(mini_batch) + " Learning Rate=" + str(
        learning_rate)
    plots.linear_plot([x for x in range(len(losses))], losses, te_losses,
                      "Iterations", "Losses", title, 1)
    np.savetxt("../adam-" + ".csv", np.array(out), delimiter="|")
    plt.savefig("../" + title + ".png")
Esempio n. 3
0
def Experiment2():

    mini_batchs = [32, 64, 128]
    i = 0
    for mini_batch in mini_batchs:
        i += 1
        keep_prob = 1
        # create model
        model = Neuralnet()
        model.add_layer(512, 1024, keep_prob=keep_prob, activation="sigmoid")
        model.add_layer(64, keep_prob=keep_prob, activation="sigmoid")
        model.add_layer(Y.shape[1], keep_prob=keep_prob, activation="no")

        # Compile model
        no_iterations = 1000
        learning_rate = 0.01
        print("Learning-Rate:- ", learning_rate, " Batch_Size:- ", mini_batch)

        losses, te_losses, out = model.train(training_f_X, training_f_Y,
                                             test_X, test_Y, learning_rate,
                                             mini_batch, no_iterations)
        print(losses)
        title = "Exp2:- Batch size=" + str(
            mini_batch) + " Learning Rate=" + str(learning_rate)
        plots.linear_plot([x for x in range(len(losses))], losses, te_losses,
                          "Iterations", "Losses", title, 1 + i)
        plt.savefig("../" + title + ".png")
        np.savetxt("../2-" + str(i) + ".csv", np.array(out), delimiter="|")
Esempio n. 4
0
import pandas as pd
import numpy as np
import plots
from matplotlib import pyplot as plt

data = pd.read_csv('4-1.csv', sep="|", header=None)
iter = data.iloc[:, 0].values
tr_losses = data.iloc[:, 1].values
te_losses = data.iloc[:, 2].values

# iter  = np.loadtxt( '2.csv' , delimiter='|', usecols=(0) )
title = "Exp4:- Batch size=" + str(64) + " Learning Rate=" + str(0.005)
plots.linear_plot(iter, tr_losses, te_losses, "Iterations", "Losses", title,
                  1 + 1)
plt.savefig(title + ".png")
plt.show()