Skip to content

Commit b6b45eb

Browse files
tianyizheng02github-actions
and
github-actions
authoredOct 15, 2023
Fix numpy deprecation warning in 2_hidden_layers_neural_network.py (#10424)
* updating DIRECTORY.md * updating DIRECTORY.md * updating DIRECTORY.md * updating DIRECTORY.md * Fix deprecation warning in 2_hidden_layers_neural_network.py Fix numpy deprecation warning: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.) --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent e6aae1c commit b6b45eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎neural_network/2_hidden_layers_neural_network.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def predict(self, input_arr: numpy.ndarray) -> int:
196196
>>> output_val = numpy.array(([0], [1], [1]), dtype=float)
197197
>>> nn = TwoHiddenLayerNeuralNetwork(input_val, output_val)
198198
>>> nn.train(output_val, 1000, False)
199-
>>> nn.predict([0,1,0]) in (0, 1)
199+
>>> nn.predict([0, 1, 0]) in (0, 1)
200200
True
201201
"""
202202

@@ -221,7 +221,7 @@ def predict(self, input_arr: numpy.ndarray) -> int:
221221
)
222222
)
223223

224-
return int(self.layer_between_second_hidden_layer_and_output > 0.6)
224+
return int((self.layer_between_second_hidden_layer_and_output > 0.6)[0])
225225

226226

227227
def sigmoid(value: numpy.ndarray) -> numpy.ndarray:

0 commit comments

Comments
 (0)