import ndarray from 'ndarray';
import ops from 'ndarray-ops';

export function dropoutLayer(arrayType, x, p=0.5) {

  let y = ndarray(new arrayType(x.size), x.shape);
  ops.muls(y, x, 1 - p);

  return y;
}

@@ -108,13 +108,256 @@
 =0.5
-) %7B%0A%0A
+, rescale=false) %7B%0A%0A  // If rescale, rescaling is done at test time,%0A  // whereas if false, it is assumed to have been done at training time.%0A  // In Keras, currently this is done during training time and rescale should be false%0A  if (rescale) %7B%0A  
   le
@@ -405,16 +405,18 @@
 ape);%0A  
+ 
+ 
 ops.muls
@@ -430,17 +430,18 @@
 1 - p);%0A
-%0A
+  
   return
@@ -444,10 +444,40 @@
 turn y;%0A
+  %7D else %7B%0A    return x;%0A  %7D%0A%0A
 %7D%0A

add rescale argument to dropout