Пример #1
0
 def test__back_propagation(self):
     data = [[1, 1, 2]]
     target = [1, 0, 0]
     nn = NeuralNetwork()
     nn.create_network(len(data[0]), 2, (1,), weights=[[-.1, .2, .1, -.4], [-.15, -.2, .3]])
     r = nn._feed_forward(data[0])
     uw = nn._back_propagation(r, target[0])
Пример #2
0
def run_iris():
    # Load iris data set
    iris = datasets.load_iris()
    n_inputs = len(iris.data[0])
    n_outputs = len(iris.target_names)
    network = NeuralNetwork()
    network.create_network(n_inputs, n_outputs, (3, 4))
    data_scaled = preprocessing.scale(iris.data)
    print("Their neural network results: {}".format(cross_val_score(nn, data_scaled, iris.target, 3)))
    print("My neural network results: {}".format(cross_val_score(network, data_scaled, iris.target, 3)))
Пример #3
0
def run_diabetes():
    data = []
    target = []
    # Read data
    with open('pima-indians-diabetes.data') as diabetes_file:
        diabetes_reader = csv.reader(diabetes_file, quoting=csv.QUOTE_NONNUMERIC)
        for row in diabetes_reader:
            data.append(row[:8])
            target.append(int(row[8]))
    n_inputs = len(data[0])
    n_outputs = len(set(target))
    network = NeuralNetwork()
    network.create_network(n_inputs, n_outputs, (3, 4))
    data_scaled = preprocessing.scale(np.array(data))
    print("Neural network results accuracy: {}".format(cross_val_score(network, data_scaled, np.array(target), 3)))
Пример #4
0
 def test__back_propagation(self):
     data = [[1, 1, 2]]
     target = [1, 0, 0]
     nn = NeuralNetwork()
     nn.create_network(len(data[0]),
                       2, (1, ),
                       weights=[[-.1, .2, .1, -.4], [-.15, -.2, .3]])
     r = nn._feed_forward(data[0])
     uw = nn._back_propagation(r, target[0])
Пример #5
0
#!/usr/bin/env python3
import sys
import random
from NeuralNetwork.neural_network import NeuralNetwork
import json
import numpy as np

with open('C:\\Users\\dbari\Documents\\GitHub\\Connect4-py\\options.json',
          'r') as file:
    options = json.load(file)

ann = NeuralNetwork(options)


class Settings():
    def __init__(self):
        self.timebank = None
        self.time_per_move = None
        self.player_names = None
        self.your_bot = None
        self.your_botid = None
        self.field_width = None
        self.field_height = None


class Field():
    def __init__(self):
        self.position = []
        self.field_state = None

    def update_field(self, celltypes, settings):