Skip to content
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

Multi Hidden Layer Support (another proposal) #107

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

maksuel
Copy link

@maksuel maksuel commented Mar 30, 2018

I refactoried the entire nn.js code.

NO CONFLICTS

Please, do not hesitate to improve!
Reference: #61
EXAMPLE: https://maksuel.github.io/Toy-Neural-Network-JS/examples/doodle_classification/
(the example use 2 hidden layers)

/**

  • Constructor method.
  • The user can enter with parameters (integer) to create a new NeuralNetwork,
  • where: the first parameter represents the number of inputs, the second
  • (or more) parameter represents the number of hidden nodes and the last
  • parameter represents the number of outputs of the network.
  • The user can copy an instance of NeuralNetwork by passing the same as an
  • argument to the constructor.
  • @param {NeuralNetwork|...Integer} args (Rest parameters)
    */

@Versatilus
Copy link
Collaborator

We would like to integrate something like this hopefully in the near future. Dan would like to do a little bit more in his streams with the simplified network first.

I'm curious why you chose to store the weights in a separate array instead of storing them in the layer objects.

@maksuel
Copy link
Author

maksuel commented Apr 15, 2018

Vesatilus,

I was looking for a more semantic way to store the variables. That was the beginning of code refactoring.
I just updated the project in the most semantic way I found, made it easier to read the methods and reduce the amount of loops.

lib/nn.js Outdated
function mutate(val) {
if (Math.random() < rate) {

if(Number(rate) !== rate || (0 < rate && rate < 1)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might be missing something here because I'm not fully awake yet, but aren't you missing a ! in there somewhere? Also, both 0 and 1 are viable, though pointless, values.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you! Went unnoticed.

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.

2 participants