From 2b636e03576dc1d544770b0ed7d0f2a0e7d6abaf Mon Sep 17 00:00:00 2001 From: Manoj Routhu <78267609+Manoj-Routhu@users.noreply.github.com> Date: Sat, 14 Oct 2023 19:35:14 +0530 Subject: [PATCH 1/4] Update simple_neural_network.py --- neural_network/simple_neural_network.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/neural_network/simple_neural_network.py b/neural_network/simple_neural_network.py index f2a3234873b5..ef98aaa446ad 100644 --- a/neural_network/simple_neural_network.py +++ b/neural_network/simple_neural_network.py @@ -24,6 +24,9 @@ def sigmoid_function(value: float, deriv: bool = False) -> float: # Initial Value INITIAL_VALUE = 0.02 +def forward_propagation(expected, number_propagations): + # Random weight initialization + weight = 2 * (random.random() - 0.5) def forward_propagation(expected: int, number_propagations: int) -> float: """Return the value found after the forward propagation training. @@ -47,8 +50,9 @@ def forward_propagation(expected: int, number_propagations: int) -> float: layer_1_error = (expected / 100) - layer_1 # Error delta layer_1_delta = layer_1_error * sigmoid_function(layer_1, True) - # Update weight - weight += INITIAL_VALUE * layer_1_delta + # Update weight using elementwise_multiply function + weight_list = elementwise_multiply(INITIAL_VALUE, layer_1_delta) + weight += sum(weight_list) return layer_1 * 100 From 1d6b28f2a0793b20a73ccdad9c5cfb66a1de8566 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:08:02 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- neural_network/simple_neural_network.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neural_network/simple_neural_network.py b/neural_network/simple_neural_network.py index ef98aaa446ad..9fc085ab2b0f 100644 --- a/neural_network/simple_neural_network.py +++ b/neural_network/simple_neural_network.py @@ -24,10 +24,12 @@ def sigmoid_function(value: float, deriv: bool = False) -> float: # Initial Value INITIAL_VALUE = 0.02 + def forward_propagation(expected, number_propagations): # Random weight initialization weight = 2 * (random.random() - 0.5) + def forward_propagation(expected: int, number_propagations: int) -> float: """Return the value found after the forward propagation training. From 57c327603777764e822cd54063496a63798f3a9c Mon Sep 17 00:00:00 2001 From: Manoj Routhu <78267609+Manoj-Routhu@users.noreply.github.com> Date: Sat, 14 Oct 2023 19:47:35 +0530 Subject: [PATCH 3/4] Update simple_neural_network.py --- neural_network/simple_neural_network.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/neural_network/simple_neural_network.py b/neural_network/simple_neural_network.py index 9fc085ab2b0f..fcc661fc6f88 100644 --- a/neural_network/simple_neural_network.py +++ b/neural_network/simple_neural_network.py @@ -21,15 +21,12 @@ def sigmoid_function(value: float, deriv: bool = False) -> float: return 1 / (1 + math.exp(-value)) +def elementwise_multiply(value, array): + return [value * x for x in array] + # Initial Value INITIAL_VALUE = 0.02 - -def forward_propagation(expected, number_propagations): - # Random weight initialization - weight = 2 * (random.random() - 0.5) - - def forward_propagation(expected: int, number_propagations: int) -> float: """Return the value found after the forward propagation training. From 936f271f4847edbdde5412462ea31a53353a5933 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:21:14 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- neural_network/simple_neural_network.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neural_network/simple_neural_network.py b/neural_network/simple_neural_network.py index fcc661fc6f88..fd9143fcb910 100644 --- a/neural_network/simple_neural_network.py +++ b/neural_network/simple_neural_network.py @@ -24,9 +24,11 @@ def sigmoid_function(value: float, deriv: bool = False) -> float: def elementwise_multiply(value, array): return [value * x for x in array] + # Initial Value INITIAL_VALUE = 0.02 + def forward_propagation(expected: int, number_propagations: int) -> float: """Return the value found after the forward propagation training.