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>
This commit is contained in:
Tianyi Zheng 2023-10-15 19:41:45 -04:00 committed by GitHub
parent e6aae1cf66
commit b6b45eb1ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,7 +196,7 @@ class TwoHiddenLayerNeuralNetwork:
>>> output_val = numpy.array(([0], [1], [1]), dtype=float)
>>> nn = TwoHiddenLayerNeuralNetwork(input_val, output_val)
>>> nn.train(output_val, 1000, False)
>>> nn.predict([0,1,0]) in (0, 1)
>>> nn.predict([0, 1, 0]) in (0, 1)
True
"""
@ -221,7 +221,7 @@ class TwoHiddenLayerNeuralNetwork:
)
)
return int(self.layer_between_second_hidden_layer_and_output > 0.6)
return int((self.layer_between_second_hidden_layer_and_output > 0.6)[0])
def sigmoid(value: numpy.ndarray) -> numpy.ndarray: