generated from javidahmed64592/template-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from javidahmed64592/add-pytest-coverage
NN v1.12.1 Add pytest coverage
- Loading branch information
Showing
12 changed files
with
180 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
|
||
from neural_network.math.activation_functions import LinearActivation, ReluActivation, SigmoidActivation | ||
|
||
|
||
class TestLinearActivation: | ||
def test_given_x_when_calculating_y_then_check_calculated_correctly(self) -> None: | ||
x = 5 | ||
expected_y = x | ||
actual_y = LinearActivation.func(x) | ||
assert actual_y == expected_y | ||
|
||
def test_given_x_when_calculating_derivative_then_check_calculated_correctly(self) -> None: | ||
x = 5 | ||
expected_y = 1 | ||
actual_y = LinearActivation.derivative(x) | ||
assert actual_y == expected_y | ||
|
||
|
||
class TestReluActivation: | ||
def test_given_x_when_calculating_y_then_check_calculated_correctly(self) -> None: | ||
x = -5 | ||
expected_y = 0 | ||
actual_y = ReluActivation.func(x) | ||
assert actual_y == expected_y | ||
|
||
x = 5 | ||
expected_y = x | ||
actual_y = ReluActivation.func(x) | ||
assert actual_y == expected_y | ||
|
||
def test_given_x_when_calculating_derivative_then_check_calculated_correctly(self) -> None: | ||
x = -5 | ||
expected_y = 0 | ||
actual_y = ReluActivation.derivative(x) | ||
assert actual_y == expected_y | ||
|
||
x = 5 | ||
expected_y = 1 | ||
actual_y = ReluActivation.derivative(x) | ||
assert actual_y == expected_y | ||
|
||
|
||
class TestSigmoidActivation: | ||
def test_given_x_when_calculating_y_then_check_calculated_correctly(self) -> None: | ||
x = 5 | ||
expected_y = 1 / (1 + np.exp(-x)) | ||
actual_y = SigmoidActivation.func(x) | ||
assert actual_y == expected_y | ||
|
||
def test_given_x_when_calculating_derivative_then_check_calculated_correctly(self) -> None: | ||
x = 5 | ||
expected_y = x * (1 - x) | ||
actual_y = SigmoidActivation.derivative(x) | ||
assert actual_y == expected_y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters