This is an automated email from the ASF dual-hosted git repository. baunsgaard pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/master by this push: new 0bf5536 [SYSTEMDS-2714] Seeded NN layers 0bf5536 is described below commit 0bf553627a7f2a55da05f355ac45d3c10457a822 Author: baunsgaard <baunsga...@tugraz.at> AuthorDate: Thu Nov 5 00:06:55 2020 +0100 [SYSTEMDS-2714] Seeded NN layers Add seeds to the initialization of affine and Conv2d layers --- scripts/nn/layers/affine.dml | 5 +++-- scripts/nn/layers/conv2d.dml | 5 +++-- scripts/nn/layers/conv2d_builtin.dml | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/nn/layers/affine.dml b/scripts/nn/layers/affine.dml index c9a740b..a2d1043 100644 --- a/scripts/nn/layers/affine.dml +++ b/scripts/nn/layers/affine.dml @@ -64,7 +64,7 @@ backward = function(matrix[double] dout, matrix[double] X, db = colSums(dout) } -init = function(int D, int M) +init = function(int D, int M, int seed = -1 ) return (matrix[double] W, matrix[double] b) { /* * Initialize the parameters of this layer. @@ -81,12 +81,13 @@ init = function(int D, int M) * Inputs: * - D: Dimensionality of the input features (number of features). * - M: Number of neurons in this layer. + * - seed: The seed to initialize the weights * * Outputs: * - W: Weights, of shape (D, M). * - b: Biases, of shape (1, M). */ - W = rand(rows=D, cols=M, pdf="normal") * sqrt(2.0/D) + W = rand(rows=D, cols=M, pdf="normal", seed=seed) * sqrt(2.0/D) b = matrix(0, rows=1, cols=M) } diff --git a/scripts/nn/layers/conv2d.dml b/scripts/nn/layers/conv2d.dml index 4fb0335..1ff115f 100644 --- a/scripts/nn/layers/conv2d.dml +++ b/scripts/nn/layers/conv2d.dml @@ -153,7 +153,7 @@ backward = function(matrix[double] dout, int Hout, int Wout, } } -init = function(int F, int C, int Hf, int Wf) +init = function(int F, int C, int Hf, int Wf, int seed = -1) return (matrix[double] W, matrix[double] b) { /* * Initialize the parameters of this layer. @@ -172,12 +172,13 @@ init = function(int F, int C, int Hf, int Wf) * - C: Number of input channels (dimensionality of depth). * - Hf: Filter height. * - Wf: Filter width. + * - seed: The seed to initialize the weights * * Outputs: * - W: Weights, of shape (F, C*Hf*Wf). * - b: Biases, of shape (F, 1). */ - W = rand(rows=F, cols=C*Hf*Wf, pdf="normal") * sqrt(2.0/(C*Hf*Wf)) + W = rand(rows=F, cols=C*Hf*Wf, pdf="normal", seed=seed ) * sqrt(2.0/(C*Hf*Wf)) b = matrix(0, rows=F, cols=1) } diff --git a/scripts/nn/layers/conv2d_builtin.dml b/scripts/nn/layers/conv2d_builtin.dml index a2c2ad4..b30ed01 100644 --- a/scripts/nn/layers/conv2d_builtin.dml +++ b/scripts/nn/layers/conv2d_builtin.dml @@ -131,7 +131,7 @@ backward = function(matrix[double] dout, int Hout, int Wout, db = util::channel_sums(dout, F, Hout, Wout) } -init = function(int F, int C, int Hf, int Wf) +init = function(int F, int C, int Hf, int Wf, int seed = -1) return (matrix[double] W, matrix[double] b) { /* * Initialize the parameters of this layer. @@ -150,12 +150,13 @@ init = function(int F, int C, int Hf, int Wf) * - C: Number of input channels (dimensionality of depth). * - Hf: Filter height. * - Wf: Filter width. + * - seed: The seed to initialize the weights * * Outputs: * - W: Weights, of shape (F, C*Hf*Wf). * - b: Biases, of shape (F, 1). */ - W = rand(rows=F, cols=C*Hf*Wf, pdf="normal") * sqrt(2.0/(C*Hf*Wf)) + W = rand(rows=F, cols=C*Hf*Wf, pdf="normal", seed=seed) * sqrt(2.0/(C*Hf*Wf)) b = matrix(0, rows=F, cols=1) }