Skip to content

Commit 23e3ce2

Browse files
committed
Merge branch 'patch-1' of https://github.com/AHuzail/Python into patch-1
2 parents f3e3a82 + 79fed0c commit 23e3ce2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

neural_network/artificial_neural_network.py

+26
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ class SimpleANN:
1111
- Example demonstrates solving the XOR problem.
1212
"""
1313

14+
<<<<<<< HEAD
1415
def __init__(self, input_size: int, hidden_size: int, output_size: int,
1516
learning_rate: float = 0.1) -> None:
17+
=======
18+
def __init__(
19+
self,
20+
input_size: int,
21+
hidden_size: int,
22+
output_size: int,
23+
learning_rate: float = 0.1,
24+
) -> None:
25+
>>>>>>> 79fed0c49891c60d2134ee45c6f6592c19f4cef5
1626
"""
1727
Initialize the neural network with random weights and biases.
1828
@@ -93,8 +103,14 @@ def feedforward(self, inputs: np.ndarray) -> np.ndarray:
93103
self.final_output = self.sigmoid(self.final_input)
94104
return self.final_output
95105

106+
<<<<<<< HEAD
96107
def backpropagation(self, inputs: np.ndarray, targets: np.ndarray,
97108
outputs: np.ndarray) -> None:
109+
=======
110+
def backpropagation(
111+
self, inputs: np.ndarray, targets: np.ndarray, outputs: np.ndarray
112+
) -> None:
113+
>>>>>>> 79fed0c49891c60d2134ee45c6f6592c19f4cef5
98114
"""
99115
Perform backpropagation to adjust the weights and biases.
100116
@@ -122,15 +138,25 @@ def backpropagation(self, inputs: np.ndarray, targets: np.ndarray,
122138
np.sum(output_gradient, axis=0, keepdims=True) * self.learning_rate
123139
)
124140

141+
<<<<<<< HEAD
125142
self.weights_input_hidden += (
126143
inputs.T.dot(hidden_gradient) * self.learning_rate
127144
)
145+
=======
146+
self.weights_input_hidden += inputs.T.dot(hidden_gradient) * self.learning_rate
147+
>>>>>>> 79fed0c49891c60d2134ee45c6f6592c19f4cef5
128148
self.bias_hidden += (
129149
np.sum(hidden_gradient, axis=0, keepdims=True) * self.learning_rate
130150
)
131151

152+
<<<<<<< HEAD
132153
def train(self, inputs: np.ndarray, targets: np.ndarray,
133154
epochs: int = 10000, verbose: bool = False) -> None:
155+
=======
156+
def train(
157+
self, inputs: np.ndarray, targets: np.ndarray, epochs: int = 10000
158+
) -> None:
159+
>>>>>>> 79fed0c49891c60d2134ee45c6f6592c19f4cef5
134160
"""
135161
Train the neural network on the given input and target data.
136162

0 commit comments

Comments
 (0)