-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor networks #7
Conversation
now fits mljs guideline and easy to add new activation functions
yes, I didn't implement the functions that receives the alpha parameter but it should be easy to do. |
don't worry about the travis failures. nodejs.org has issues at the moment: nodejs/build#562 |
Looks good! |
It seems that all layers get the same activation with this commit? Also wouldn't it be better to allow activation function parameters to be passed as an object
and then the activation functions can pick out whatever parameters necessary? |
ok, I will change the activation params. I you can pass the parameters as an array or object but now the current parametric activation functions takes only 1 argument as the Wikipedia functions that you propose... |
@@ -0,0 +1,88 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use a lower case name for this file (it doesn't export a class)
|
||
var Matrix = require('ml-matrix'); | ||
|
||
class Utils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make it a usual export of functions instead of a class ?
Then the filename can be lowercase
* @param {Matrix} B | ||
* @return {Matrix} A | ||
*/ | ||
static matrixSum(A, B) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the same as A.add(B) ? Same question for the other methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the current version of matrix I didn't find those methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,3 +1,3 @@ | |||
'use strict'; | |||
|
|||
module.exports = require('./feedforwardNeuralNetwork'); | |||
module.exports = require('./FeedForwardNeuralNetwork'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of re-exporting FeedForwardNeuralNetwork from here, you can remove this file and change the main
field in package.json
* @return {Matrix} the new delta values for the next layer. | ||
*/ | ||
backpropagation(delta, a) { | ||
this.dW = a.transpose().mmul(delta); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can win some time and memory by using a Matrix view for the transpose here and in other places. Just replace a.transpose()
with a.transposeView()
.
This is a relatively new feature. You can see how it works here: https://github.com/mljs/matrix/blob/master/src/views/transpose.js
And the list of currently implemented views: https://mljs.github.io/matrix/#Matrix#transposeView
also small changes on filenames and export methods.
I'm getting a timeout error, should I do a shorter test? |
If you know it will take less than say 10secs, you can call |
ok, those changes are now ok? @targos |
Thanks, I'll finish the review tomorrow |
|
||
var Layer = require('./Layer'); | ||
var OutputLayer = require('./OutputLayer'); | ||
var Utils = require('./utils'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use const
for this cases?
* @param {number} [options.activationParam=1] - if the selected activation function needs a parameter. | ||
*/ | ||
constructor(options) { | ||
if (options === undefined) options = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options = options || {}
it's just nicer
this.activation = options.activation === undefined ? 'tanh' : options.activation; | ||
this.activationParam = options.activationParam === undefined ? 1 : options.activationParam; | ||
if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) { | ||
//console.warn("Setting default activation function: 'tanh'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this old code commented should be removed or at least comment why it's commented like this
Ok, I added your changes @maasencioh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any outstanding issue. If @maasencioh is OK with it, you can merge. Do not forget to make a major version bump if you release it, because the API has changed.
For me you can merge, thanks! |
A better implementation of the neural nets that allows to add new activation functions easily