-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayer.py
More file actions
31 lines (28 loc) · 1.21 KB
/
layer.py
File metadata and controls
31 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Creator : Jayrese Heslop
Created on : 5/26/2016 (11:08 P.M.)
Last Editted: 6/11/2016 (01:38 P.M.)
"""
from neuron import Neuron
class Layer(object):
"""
A layer is a layer of neurons in a neural network (sometimes called Synapses)
@property (Array<Neuron>) neurons - The neurons in the layer
"""
def __init__(self, num_neurons, num_inputs, activation, derivative):
"""
Initializes a layer of neurons
@param (Number) num_neurons - The number of neurons in the layer
@param (Number) num_inputs - The number of inputs of each neuron in the layer
@param (Function) activation - The activation function to be used
@param (Function) derivative - The derivative of the activation function
@returns (Layer)
"""
self.neurons = [Neuron(num_inputs, activation, derivative) for i in range(0, num_neurons, 1)]
def process(self, inputs):
"""
Processes a set of inputs
@param (Array<Number>) inputs - The inputs to process
@returns (Array<Number>) - The output of the layer
"""
return [neuron.process(inputs) for neuron in self.neurons]