Skip to content

Commit 2b636e0

Browse files
authored
Update simple_neural_network.py
1 parent 37cae3f commit 2b636e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

neural_network/simple_neural_network.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def sigmoid_function(value: float, deriv: bool = False) -> float:
2424
# Initial Value
2525
INITIAL_VALUE = 0.02
2626

27+
def forward_propagation(expected, number_propagations):
28+
# Random weight initialization
29+
weight = 2 * (random.random() - 0.5)
2730

2831
def forward_propagation(expected: int, number_propagations: int) -> float:
2932
"""Return the value found after the forward propagation training.
@@ -47,8 +50,9 @@ def forward_propagation(expected: int, number_propagations: int) -> float:
4750
layer_1_error = (expected / 100) - layer_1
4851
# Error delta
4952
layer_1_delta = layer_1_error * sigmoid_function(layer_1, True)
50-
# Update weight
51-
weight += INITIAL_VALUE * layer_1_delta
53+
# Update weight using elementwise_multiply function
54+
weight_list = elementwise_multiply(INITIAL_VALUE, layer_1_delta)
55+
weight += sum(weight_list)
5256

5357
return layer_1 * 100
5458

0 commit comments

Comments
 (0)