Пример #1
0
    epochs = 1000
    lr = 0.1
    goal_loss = 0.01

    neurons_number = [35, 10]

    opt_name = "Adam"

    optimizer = Adam(lr=lr, decay=0.0001)

    draw_step = 10
    verbose = 1

    # 2 model and data initializing---------------------------------------------------------
    (x_train, y_train), (x_test,
                         y_test) = dataset5.load_data(train_size=train_size,
                                                      show=False)

    x_train = np.transpose(
        np.append(x_train, np.ones(x_train.size)).reshape(2, x_train.size))
    x_test = np.transpose(
        np.append(x_test, np.ones(x_test.size)).reshape(2, x_test.size))

    model = Sequential()

    model.add(Dense(neurons_number[0], input_dim=2, activation='sigmoid'))
    model.add(Dense(neurons_number[1], activation='sigmoid'))

    model.add(Dense(1, activation='linear'))

    # 3 setting stopper---------------------------------------------------------
    callbacks = [
Пример #2
0
import LABS.ZeroLab.E_Function as dataset5

from neupy import algorithms
import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    (x_train, y_train), (x_test, y_test) = dataset5.load_data(train_size=6000, show=False)
    for std in [0.1, 0.01, 0.001]:
        nw = algorithms.GRNN(std=std, verbose=True)

        nw.train(x_train, y_train)

        y_pred = nw.predict(x_test)

        mae = (np.abs(y_test - y_pred)).mean()

        plt.plot(x_test, y_test, 'b.', label='real')
        plt.plot(x_test, y_pred, 'r.', label='fit')
        plt.legend(loc='upper right')
        plt.title('GRNN aprox with neupy\nstd = %.4f\nmae = %.3f' % (std,mae))
        plt.show()
Пример #3
0
def get_index(poss_code):
    for i in range(poss_code.__len__()):
        if poss_code[i] == 1:
            return i


if __name__ == '__main__':

    epochs = 100
    step = 0.5
    train_size = 4000

    goal_loss = 0.01

    (x_train, y_train), (x_test,
                         y_test) = dataset5.load_data(train_size=train_size,
                                                      mode=1)

    data = zip(x_train, y_train)

    for m in [5]:
        sofm = algorithms.SOFM(n_inputs=2,
                               n_outputs=m * m,
                               step=step,
                               show_epoch=20,
                               verbose=True,
                               learning_radius=1,
                               features_grid=(m, m, 1),
                               epoch_end_signal=on_epoch_end)

        sofm.train(data, epochs=10)