parser.add_argument('--plot', dest='plot', action='store_const', const=True, default=False, help='plots the NN weights') parser.add_argument('-i', dest='interactive', action='store_const', const=True, default=False, help='once done training starts an interactive mode') args = parser.parse_args() # init xornn = NN(2, 10, 1, 3, actifunc, dactifunc, 0.1) # load brain if args.load: with open(args.load) as f: xornn.load_brain(json.load(f)) # training for x in range(args.train_amount): inputs = [random.randint(0, 1), random.randint(0, 1)] goal_output = [inputs[0] ^ inputs[1]] xornn.backpropagate(inputs, goal_output) # testing if args.test: for i in range(2): for j in range(2): print(f'{i} ^ {j} == {xornn.feedforward([i, j])[0]}') # plotting if args.plot:
parser.add_argument('-i', dest='interactive', action='store_const', const=True, default=False, help='once done training starts an interactive mode') args = parser.parse_args() # init calcnn = NN(3, 10, 1, 3, actifunc, dactifunc, 0.1) # load brain if args.load: with open(args.load) as f: calcnn.load_brain(json.load(f)) # data traindata = [] testdata = [] with open('./train.txt') as f: for line in f.readlines(): traindata.append(dataline(line)) with open('./test.txt') as f: for line in f.readlines(): testdata.append(dataline(line)) # training inputs = list(map(lambda x: x.mapped_inputs(), traindata)) goal_ouputs = list(map(lambda x: x.mapped_result(), traindata)) calcnn.train(inputs, goal_ouputs, args.train_amount)