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

[SYSTEMML-540] [SYSTEMML-515] Allow an expression for sparsity #351

Closed
wants to merge 2 commits into from

Conversation

niketanpansare
Copy link
Contributor

  • This PR also improves the performance of dropout

@bertholdreinwald @mboehm7 @dusenberrymw

- This PR improves the performance of dropout
@mboehm7
Copy link
Contributor

mboehm7 commented Jan 19, 2017

Please also fix it for MR - you can simply use instruction patching as done for rows and cols.

Copy link
Contributor

@dusenberrymw dusenberrymw left a comment

Choose a reason for hiding this comment

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

Thanks, @niketanpansare for adding this functionality! I added a couple of comments to dropout.dml, but otherwise this will be great.

@@ -42,10 +42,7 @@ forward = function(matrix[double] X, double p, int seed)
* - out: Ouptuts, of same shape as X.
* - mask: Dropout mask used to compute the output.
*/
if (seed == -1) {
seed = as.integer(floor(as.scalar(rand(rows=1, cols=1, min=1, max=100000))))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These three lines need to be added back so that a user can indicate that the dropout layer should use a random seed.

if (seed == -1) {
seed = as.integer(floor(as.scalar(rand(rows=1, cols=1, min=1, max=100000))))
}
mask = rand(rows=nrow(X), cols=ncol(X), min=0, max=1, seed=seed) <= p
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment here explaining how we are creating the mask with the sparsity flag, since that is not a common construct? I.e. add the following comment:

# Normally, we might use something like
#    `mask = rand(rows=nrow(X), cols=ncol(X), min=0, max=1, seed=seed) <= p`
# to create a dropout mask.  Fortunately, SystemML has a `sparsity` parameter on
# the `rand` function that allows use to create a mask directly.
mask = rand(rows=nrow(X), cols=ncol(X), min=1, max=1, sparsity=p, seed=seed)

// if(!(getVarParam(RAND_SPARSITY) instanceof DoubleIdentifier || getVarParam(RAND_SPARSITY) instanceof IntIdentifier
// || getVarParam(RAND_SPARSITY) instanceof DataIdentifier)) {
// raiseValidateError("for Rand statement " + RAND_SPARSITY + " has incorrect value type", conditional);
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just remove this code?

@niketanpansare
Copy link
Contributor Author

@mboehm7 @dusenberrymw Incorporated your comments, please review it.

@dusenberrymw Instead of generating random seed in DML, we can let rand chose a random seed instead by not providing it an argument :)

Copy link
Contributor

@dusenberrymw dusenberrymw left a comment

Choose a reason for hiding this comment

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

Great! I just ran the SystemML-NN tests as well, and everything passes still.

LGTM.

@niketanpansare
Copy link
Contributor Author

The integration tests passed as well.

@asfgit asfgit closed this in 42ebc96 Jan 19, 2017
j143-zz pushed a commit to j143-zz/systemml that referenced this pull request Nov 4, 2017
- This PR also improves the performance of dropout.

Closes apache#351.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants