'Iris-versicolor': [0, 1, 0], 'Iris-virginica': [1, 0, 0] } learning_data = [] with open('../data/training_data/iris.data', newline='') as csvfile: reader = csv.reader(csvfile) for row in reader: learning_data.append({ 'inputs': [float(x) for x in row[0:4]], 'outputs': iris_map[row[4]] }) map = load_som("../data/trained_networks/som.yaml") inputs = InputLayer([1, 1, 1, 1], name='NormalInput') inputs_som = InputSom([1, 1, 1, 1], map) inputs_som.set_network_name('som') middle = Layer(3) output = OutputLayer([1, 1, 1]) network = Network([inputs, middle, output], 'som') network.connect() network.load_learning_data(learning_data) middle.connect_layer(inputs_som, 'left') network.dump_cypher('../data/cypher/som.cypher', additional_neurons=inputs_som.neurons) """ #network.learn(times=5000) #input_layers=[inputs_som]) folds = 4 results = network.learn_kfolds(folds, times=1000)
from pprint import pprint from random import uniform from time import time from core.layer import Layer, InputLayer, OutputLayer from core.network import Network with open('snek-learning.yaml', 'r') as file: data = yaml.load(file) #data = data[:1000] learning_data = [{'inputs': list(row[:5]), 'outputs': [row[5]]} for row in data] inputs = InputLayer([1, 1, 1, 1, 1]) middle = Layer(5) middle3 = Layer(3) output = OutputLayer([1]) network = Network([inputs, middle, middle3, output], 'snek') network.connect() network.load_learning_data(learning_data) network.print_data() folds = 4 result = [0] i = 0 start_time = time() while sum(result) / folds < 90: results = network.learn_kfolds(folds, times=1)
from core.layer import Layer, InputLayer, OutputLayer from core.network import Network learning_data = [] tic_tac_map = {'positive': 1, 'negative': 0, 'x': 1, 'o': 2, 'b': 3} with open('data/training_data/tic-tac-toe.data', newline='') as csvfile: reader = csv.reader(csvfile) for row in reader: learning_data.append({ 'inputs': [tic_tac_map[x] for x in row[0:9]], 'outputs': [tic_tac_map[row[9]]] }) inputs = InputLayer([1] * 9) middle = Layer(5) middle2 = Layer(7) middle3 = Layer(5) middle4 = Layer(2) output = OutputLayer([1]) network = Network([inputs, middle, middle2, middle3, middle4, output]) network.connect() network.load_learning_data(learning_data) #network.normalize_learning_data() print("------- learn -------") network.print_data()