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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)))) | ||
} | ||
mask = rand(rows=nrow(X), cols=ncol(X), min=0, max=1, seed=seed) <= p | ||
mask = rand(rows=nrow(X), cols=ncol(X), min=1, max=1, sparsity=p, seed=seed) | ||
out = X * mask / p | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ | |
import org.apache.hadoop.fs.FileStatus; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.sysml.api.DMLScript; | ||
import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; | ||
import org.apache.sysml.conf.CompilerConfig.ConfigType; | ||
import org.apache.sysml.conf.ConfigurationManager; | ||
import org.apache.sysml.hops.DataGenOp; | ||
|
@@ -1163,9 +1165,10 @@ else if (dataParam instanceof StringIdentifier) { | |
} | ||
|
||
//parameters w/o support for variable inputs (requires double/int or string constants) | ||
if (!(getVarParam(RAND_SPARSITY) instanceof DoubleIdentifier || getVarParam(RAND_SPARSITY) instanceof IntIdentifier)) { | ||
raiseValidateError("for Rand statement " + RAND_SPARSITY + " has incorrect value type", conditional); | ||
} | ||
// 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); | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just remove this code? |
||
|
||
if (!(getVarParam(RAND_PDF) instanceof StringIdentifier)) { | ||
raiseValidateError("for Rand statement " + RAND_PDF + " has incorrect value type", conditional); | ||
|
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.
These three lines need to be added back so that a user can indicate that the dropout layer should use a random seed.