Commit 36f09b8e authored by Steven Jude Iovine's avatar Steven Jude Iovine
Browse files

Something...Maybe?

parent 7aa1fedc
......@@ -12,7 +12,11 @@ import math
import tensorflow
from tensorflow import keras
from tensorflow import keras, random
from keras.models import Sequential
from keras.layers import Activation, Dense
import matplotlib.pyplot as plt
......@@ -85,8 +89,11 @@ class NeuralMMAgent(object):
self.momentum = momentum
self.random_seed = random_seed
self.num_hid_layers = num_hid_layers
self.random_seed = random_seed
random.set_seed(self.random_seed)
self.model = keras.models.Sequential()
......@@ -111,19 +118,22 @@ class NeuralMMAgent(object):
'''
#train model
model = self.model.fit(input_list, output_list, batch_size=32, epochs=2000)
# Some code...#
all_err.append(total_err)
#all_err.append(total_err)
if (total_err < max_sse):
#if (total_err < max_sse): # from < to >
"break"
# exit
# Show us how our error has changed
plt.plot(all_err)
#plt.plot(all_err)
plt.show()
......@@ -164,8 +174,7 @@ class NeuralMMAgent(object):
@staticmethod
def create_neural_structure(num_in, num_hid, num_hid_layers, num_out, rand_obj):
def create_neural_structure(self, num_in, num_hid, num_hid_layers, num_out, rand_obj):
""" Creates the structures needed for a simple backprop neural net
......@@ -204,6 +213,24 @@ class NeuralMMAgent(object):
6th - 2D list for thetas deltas
"""
#First layer/inputs
layer1 = Dense(num_in, input_shape=(num_in,), activation = 'sigmoid')
self.model.add(layer1)
#Creating hidden layers
for i in range(num_hid_layers):
self.model.add(Dense(num_hid, activation = 'sigmoid'))
#output layer
layer4 = Dense(num_out,activation = 'sigmoid')
self.model.add(layer4)
#compile model
self.model.compile(optimizer='Adam', loss = 'mean_squared_error')
......@@ -237,11 +264,13 @@ test_in = [[1, 0], [0, 0], [1, 1], [0, 1]]
test_out = [[1], [0], [0], [1]]
test_agent.create_neural_structure(test_agent, 2, 2, 1, 1, test_agent.random_seed)
#test_agent.set_weights([[-.37, .26, .1, -.24], [-.01, -.05]])
#test_agent.set_thetas([[0, 0], [0, 0], [0]])
#test_agent.train_net(test_in, test_out,
test_agent.train_net(test_in, test_out,
# max_sse=test_agent.max_sse, max_num_epoch=test_agent.max_epoch)
max_sse=test_agent.max_sse, max_num_epoch=test_agent.max_epoch)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment