コード例 #1
0
                                                     Y_indeces)

                    training_model = NeuralNetwork(X_training, Y_training,
                                                   hidden_layers_neurons, alfa,
                                                   _lambda)
                    training_model.fit(iterations)

                    validation_model = NeuralNetwork(X_validation,
                                                     Y_validation,
                                                     hidden_layers_neurons,
                                                     alfa, _lambda)
                    validation_model.network = training_model.network
                    validation_model.bias_weights = training_model.bias_weights

                    total_RMSE += validation_model.RMSE()
                    total_MSE += validation_model.MSE()
                    total_MAE += validation_model.MAE()
                    total_squaredR += validation_model.squaredR()

                total_RMSE = total_RMSE / len(datasets)
                total_MSE = total_MSE / len(datasets)
                total_MAE = total_MAE / len(datasets)
                total_squaredR = total_squaredR / len(datasets)

                print('lambda', _lambda, 'alfa', alfa, 'nuerons',
                      hidden_layers_neurons)
                print('RMSE ', total_RMSE)
                print('MSE ', total_MSE)
                print('MAE ', total_MAE)
                print('total_squaredR', total_squaredR.item((0, 0)))
                print('\n\n')
コード例 #2
0
        params = pickle.load(infile)
        w = params[0]
        norm = params[1]
        normFeatures = norm[0]
        normLabels = norm[1]

    test_path = conf.TEST_PATH
    s = str(
        input("Enter test file path or enter x to use \"" + test_path +
              "\": "))
    if (s != "x"):
        test_path = s
    print("Using test path: " + test_path)
    data = Data(test_path, normFeatures, normLabels)
    nn = NeuralNetwork(data.structure, conf.sigmoid, conf.sigmoidDeriv, w)
    print("MSE On test data = " + str(nn.MSE(data.data)))
    while (True):
        s = str(input("Do you want to test one more example [y/n]: "))
        if (s == "n"):
            break
        inp = [1]
        for i in range(data.inSize - 1):
            inp.append(float(input("Enter iput for feature #" + str(i) +
                                   ": ")))

        x = np.array(inp)
        x -= normFeatures[0]
        x /= normFeatures[1]

        y = nn.forward(x)
        y *= normLabels[1]