Skip to content

Adding 2-hidden layer neural network with back propagation using sigmoid activation function #4037

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

Conversation

raman77768
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}.

@ghost ghost added awaiting reviews This PR is ready to be reviewed require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html and removed awaiting reviews This PR is ready to be reviewed labels Dec 14, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@ghost ghost removed the require type hints https://docs.python.org/3/library/typing.html label Dec 14, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@ghost ghost added the tests are failing Do not merge until tests pass label Dec 14, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@ghost ghost removed the tests are failing Do not merge until tests pass label Dec 14, 2020
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed require tests Tests [doctest/unittest/pytest] are required labels Dec 14, 2020
@raman77768 raman77768 closed this Dec 16, 2020
@raman77768 raman77768 reopened this Dec 16, 2020
@TheAlgorithms TheAlgorithms deleted a comment Dec 21, 2020
@TheAlgorithms TheAlgorithms deleted a comment Dec 21, 2020
@cclauss
Copy link
Member

cclauss commented Dec 21, 2020

@dhruvmanila Your review, please?

@dhruvmanila
Copy link
Member

@algorithms-keeper review

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@dhruvmanila
Copy link
Member

@raman77768 Please resolve the conversation for which the changes have been implemented, that will make the review process easier.

@raman77768
Copy link
Contributor Author

@dhruvmanila Resolved the conversations where changes were made.

@raman77768 raman77768 requested a review from cclauss December 25, 2020 09:54
Copy link
Member

@cclauss cclauss 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 to me. Thanks for your persistence!!

@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Dec 25, 2020
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

mypy still complains:

$ mypy 2_hidden_layers_neural_network.py
2_hidden_layers_neural_network.py:95: error: No return value expected
2_hidden_layers_neural_network.py:114: error: "float" has no attribute "T"
2_hidden_layers_neural_network.py:120: error: "float" has no attribute "T"
2_hidden_layers_neural_network.py:179: error: "feedforward" of "TwoHiddenLayerNeuralNetwork" does not return a value
2_hidden_layers_neural_network.py:182: error: "feedforward" of "TwoHiddenLayerNeuralNetwork" does not return a value

@ghost ghost added the awaiting changes A maintainer has requested changes to this PR label Dec 25, 2020
@dhruvmanila dhruvmanila removed the require proper documentation Requested to write the documentation properly label Dec 25, 2020
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Dec 25, 2020
@dhruvmanila
Copy link
Member

@raman77768 Please run mypy locally and fix all the errors. If you have any doubt, feel free to ask.

@raman77768
Copy link
Contributor Author

image

@dhruvmanila
error: "float" has no attribute "T", Here i am using .T(i.e. transpose on numpy array) from numpy library but it is stating them as float values

@dhruvmanila
Copy link
Member

That is because you provided the incorrect type hint for the parameter and for the function sigmoid and also sigmoid_derivative. You are stating that it returns a float value, thus the variable became float and when you try to access T, mypy complains correctly.

Another thing to note is that numpy does not provide type hints, so work accordingly.

Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

Awesome work! LGTM! 🎉
Thanks for the patience and persistence! Appreciate it! 👍

@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Dec 26, 2020
@dhruvmanila dhruvmanila merged commit 64d8504 into TheAlgorithms:master Dec 26, 2020
@raman77768 raman77768 deleted the 2_hidden_layer_neural_network branch December 26, 2020 16:16
@cclauss
Copy link
Member

cclauss commented Dec 26, 2020

Yeah!! 64 comments! Is that a record?

@dhruvmanila
Copy link
Member

Lol, a record for what? Also, some of the reviews were made by the bot ;-)

stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
… activation function (TheAlgorithms#4037)

* added neural network with 2 hidden layers

* Revert "added neural network with 2 hidden layers"

This reverts commit fa4e2ac.

* added neural network with 2 hidden layers

* passing pre-commit requirements

* doctest completed

* added return hints

* added example

* example added

* completed doctest's

* changes made as per the review

* changes made

* changes after review

* changes

* spacing

* changed return type

* changed dtype
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
… activation function (TheAlgorithms#4037)

* added neural network with 2 hidden layers

* Revert "added neural network with 2 hidden layers"

This reverts commit fa4e2ac.

* added neural network with 2 hidden layers

* passing pre-commit requirements

* doctest completed

* added return hints

* added example

* example added

* completed doctest's

* changes made as per the review

* changes made

* changes after review

* changes

* spacing

* changed return type

* changed dtype
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
… activation function (TheAlgorithms#4037)

* added neural network with 2 hidden layers

* Revert "added neural network with 2 hidden layers"

This reverts commit fa4e2ac.

* added neural network with 2 hidden layers

* passing pre-commit requirements

* doctest completed

* added return hints

* added example

* example added

* completed doctest's

* changes made as per the review

* changes made

* changes after review

* changes

* spacing

* changed return type

* changed dtype
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
… activation function (TheAlgorithms#4037)

* added neural network with 2 hidden layers

* Revert "added neural network with 2 hidden layers"

This reverts commit fa4e2ac.

* added neural network with 2 hidden layers

* passing pre-commit requirements

* doctest completed

* added return hints

* added example

* example added

* completed doctest's

* changes made as per the review

* changes made

* changes after review

* changes

* spacing

* changed return type

* changed dtype
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