Ejemplo n.º 1
0
    def setUp(self):

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

        self.rec_config = ElmanSimpleRecurrent()
Ejemplo n.º 2
0
 y_train = np.array(y_train).reshape((len(y_train), 1))
 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
 fit1 = NeuralNet()
 fit1.init_layers(input_nodes, [hidden_nodes], output_nodes,
                  ElmanSimpleRecurrent())
 fit1.randomize_network()
 fit1.layers[1].set_activation_type('sigmoid')
 fit1.set_learnrate(0.05)
 fit1.set_all_inputs(x_input)
 fit1.set_all_targets(y_input)
 fit1.set_learn_range(0, i)
 fit1.set_test_range(i, i + 1)
 fit1.learn(epochs=100, show_epoch_results=True, random_testing=False)
 mse = fit1.test()
 all_mse.append(mse)
 print("test set MSE = ", np.round(mse, 6))
 target = [item[0][0] for item in fit1.test_targets_activations]
 target = scaler_y.inverse_transform(
     np.array(target).reshape((len(target), 1)))
 pred = [item[1][0] for item in fit1.test_targets_activations]