Skip to content

Add simple neural network #6452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 30, 2022

Conversation

CaioCordeiro
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Tests Results:

Trying:
    res = forward_propagation(32, 10000000)
Expecting nothing
ok
Trying:
    res > 31 and res < 33
Expecting:
    True
ok
Trying:
    res = forward_propagation(32, 1000)
Expecting nothing
ok
Trying:
    res > 31 and res < 33
Expecting:
    False
ok
Trying:
    sigmoid_function(3.5)
Expecting:
    0.9706877692486436
ok
Trying:
    sigmoid_function(3.5, True)
Expecting:
    -8.75
ok
1 items had no tests:
    simple_neural_network
2 items passed all tests:
   4 tests in simple_neural_network.forward_propagation
   2 tests in simple_neural_network.sigmoid_function
6 tests in 3 items.
6 passed and 0 failed.
Test passed.

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 1, 2022
@CaioCordeiro
Copy link
Contributor Author

@CaedenPH Could you check this one? The other one got closed when I was fixing the pre-commit.

Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
As a side note, you could also implement a simple doctest check

@CaioCordeiro
Copy link
Contributor Author

Looks good. As a side note, you could also implement a simple doctest check

Sure, could you show me an example?

@CaedenPH
Copy link
Contributor

CaedenPH commented Oct 1, 2022

Looks good. As a side note, you could also implement a simple doctest check

Sure, could you show me an example?

Very simple, just ```py
if name == "main":
import doctest

doctest.testmod()
@CaioCordeiro 

@CaioCordeiro CaioCordeiro requested a review from CaedenPH October 1, 2022 10:01
https://towardsdatascience.com/forward-propagation-in-neural-networks-simplified-math-and-code-version-bbcfef6f9250
"""

import doctest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import doctest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



if __name__ == "__main__":
print(doctest.testmod())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(doctest.testmod())
import doctest
doctest.testmod()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import doctest

doctest.testmod()
expected = int(input("Expected value: "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected = int(input("Expected value: "))
expected = int(input("Expected value: "))

@CaioCordeiro CaioCordeiro requested a review from CaedenPH October 1, 2022 10:18
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 30, 2022
@cclauss cclauss merged commit f340bde into TheAlgorithms:master Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants