import numpy
import scipy.special
class nnet:
def __init__(self, input_cnt, hidden_cnt, output_cnt, learning_rate):
self.input_cnt = input_cnt
self.hidden_cnt = hidden_cnt
self.output_cnt = output_cnt
self.learning_rate = learning_rate
self.wih = numpy.random.normal(0.0, pow(self.hidden_cnt, -0.5), (self.hidden_cnt, self.input_cnt))
self.who = numpy.random.normal(0.0, pow(self.output_cnt, -0.5), (self.output_cnt, self.hidden_cnt))
self.activation = lambda x: scipy.special.expit(x)
pass
def train():
pass
def query(self, inputs_list):
inputs_arr = numpy.array(inputs_list, ndmin=2)
hidden_inputs = numpy.dot(self.wih, inputs_arr)
hidden_outputs = self.activation(hidden_inputs)
final_inputs = numpy.dot(self.who, hidden_outputs)
final_outputs = self.activation(final_inputs)
return final_outputs
n = nnet(3, 3, 3, 0.3)
n.query([1.0, 0.5, -1.5])