def neuro_start(inputs, targets, training): #initializes the neural network network=neuro.setup_network(inputs) #The number of repetitions that you will #be training your network with training_reps= training #trains your neural network neuro.train(network, inputs, targets, training_reps) total = 0 correct = 0 for i in range(1,10): for x in range(1,10): pred = neuro.predict(network, [i+x]) #rounds the predicted value to either 0 or 1 #print '{} == pred {}'.format(i+x,pred) pred = np.round(pred) if (i+x)%2 == pred: correct+= 1 total += 1 percent = (correct/total) * 100 #print 'with training: {}'.format(training_reps) #print 'correct: {}\n total: {} \n {:.2f}%'.format(correct, total, (correct/total) * 100) return training_reps, percent, correct, total
# inputs.pop() # newT = [] # targets = open('myTest.csv', 'r') # targets = targets.read() # targets = targets.split('\n') # if targets[-1] == '': # targets.pop() # for i in targets: # newT.append(i.split(',')) # print(float(newT)) reps = 1000 network = [] netowrk = neuro.setup_network(inputs) neuro.train(network, inputs, targets, reps) neuro.writeNetworkToFile('myNetwork.net', network) count = 0 myGrid = open('myNetwork.csv', 'w+') def search(x, y): if grid[x][y] == 2: print('Solved... This is a Maze!') return True elif grid[x][y] == 1: print('Wall! at %d, %d' % (x, y)) return False elif grid[x][y] == 3: print('Visiting %d, %d' % (x, y))
def main(): a, b, c, d = load_data_1() m = neuro.create_model() neuro.train(a, b, c, d, m) neuro.ploting()