34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import numpy as np
|
|
|
|
import NNLayer
|
|
|
|
|
|
class NeuralNetwork:
|
|
def __init__(self, input_size, hidden_sizes, output_size):
|
|
self.input_size = input_size
|
|
self.hidden_sizes = hidden_sizes
|
|
self.output_size = output_size
|
|
|
|
def hidden_activation_function(self, x):
|
|
self.hidden_activation = x
|
|
|
|
def hidden_activation_derivative(self, x):
|
|
self.hidden_activation_derivative = x
|
|
|
|
def output_activation_function(self, x):
|
|
self.output_activation = x
|
|
|
|
def output_activation_derivative(self, x):
|
|
self.output_activation_derivative = x
|
|
|
|
def create_hidden_layers(self):
|
|
self.layers = [NNLayer.NNLayer(self.input_size, self.output_size, self.hidden_activation, self.hidden_activation_derivative())
|
|
for _ in range(len(self.hidden_sizes))]
|
|
|
|
def forward(self, input_data):
|
|
activation = np.array([])
|
|
|
|
for layer in self.layers:
|
|
activation = np.append(activation, layer.forward(input_data))
|
|
|
|
return activation |