예제 #1
0
    def setUp(self):

        self.net = NeuralNet()
        self.net.init_layers(2, [1], 1)

        self.rec_config = JordanRecurrent(existing_weight=.8)
예제 #2
0
 y_test = np.array(y_test).reshape((len(y_test), 1))
 #transformando os dados para estar no intervalo de 0 a 1
 scaler_x = MinMaxScaler()
 x_train = scaler_x.fit_transform(x_train)
 x_test = scaler_x.transform(x_test)
 scaler_y = MinMaxScaler()
 y_train = scaler_y.fit_transform(y_train)
 y_test = scaler_y.transform(y_test)
 x_input = np.concatenate(
     (x_train, x_test, np.zeros((1, np.shape(x_train)[1]))))
 y_input = np.concatenate((y_train, y_test, np.zeros((1, 1))))
 #elaboracao do modelo de rede neural com os parametros definidos
 fit2 = NeuralNet()
 fit2.init_layers(input_nodes_jordan, [hidden_nodes_jordan],
                  output_nodes_jordan,
                  JordanRecurrent(existing_weight_factor))
 fit2.randomize_network()
 fit2.layers[1].set_activation_type('sigmoid')
 fit2.set_learnrate(0.05)
 fit2.set_all_inputs(x_input)
 fit2.set_all_targets(y_input)
 fit2.set_learn_range(0, i)
 fit2.set_test_range(i, i + 1)
 fit2.learn(epochs=100, show_epoch_results=True, random_testing=False)
 mse = fit2.test()
 all_mse_jordan.append(mse)
 print("test set MSE = ", np.round(mse, 6))
 target = [item[0][0] for item in fit2.test_targets_activations]
 target = scaler_y.inverse_transform(
     np.array(target).reshape((len(target), 1)))
 pred = [item[1][0] for item in fit2.test_targets_activations]