[mlpack-git] master: 1 : add function Ratio to set the ratio parameter and set the scale parameter 2 : avoid passing input matrix twice (be45bc4)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Nov 20 11:16:41 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/c99256848a352da3c59610c8e37a21d0d5be9736...d69ac29a1c33b4e303b79ac7af939cc4cb37edd4

>---------------------------------------------------------------

commit be45bc4a48b908f9be3ab39fb6bedf006c5ce12f
Author: stereomatchingkiss <stereomatchingkiss at gmail.com>
Date:   Tue Nov 10 12:11:14 2015 +0800

    1 : add function Ratio to set the ratio parameter and set the scale parameter
    2 : avoid passing input matrix twice


>---------------------------------------------------------------

be45bc4a48b908f9be3ab39fb6bedf006c5ce12f
 src/mlpack/methods/ann/layer/dropout_layer.hpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/methods/ann/layer/dropout_layer.hpp b/src/mlpack/methods/ann/layer/dropout_layer.hpp
index da7614b..c633244 100644
--- a/src/mlpack/methods/ann/layer/dropout_layer.hpp
+++ b/src/mlpack/methods/ann/layer/dropout_layer.hpp
@@ -77,10 +77,10 @@ class DropoutLayer
     // (during testing).
     if (deterministic)
     {      
-      output = input;
-
-      if (rescale)
-        output *= scale;
+      if (!rescale)
+        output = input;
+	  else
+		output = input * scale;
     }
     else
     {
@@ -163,6 +163,12 @@ class DropoutLayer
   //! Modify the probability of setting a value to zero.
   double& Ratio() {return ratio; }
   
+  void Ratio(double r)
+  {
+	ratio = r;
+	scale = 1.0 / (1.0 - ratio);
+  }
+
   //! The value of the rescale parameter.
   bool Rescale() const {return rescale; }
   //! Modify the value of the rescale parameter.



More information about the mlpack-git mailing list