public override Vol forward(Vol V, bool is_training) { this.in_act = V; var V2 = V.clone(); var N = V.w.Length; if (is_training) { // do dropout for (var i = 0; i < N; i++) { if (rnd.NextDouble() < this.drop_prob) { V2.w[i] = 0; this.dropped[i] = true; } // drop! else { this.dropped[i] = false; } } } else { // scale the activations during prediction for (var i = 0; i < N; i++) { V2.w[i] *= this.drop_prob; } } this.out_act = V2; return(this.out_act); // dummy identity function for now }
public override Vol forward(Vol V, bool is_training) { this.in_act = V; var V2 = V.clone(); var N = V.w.Length; var V2w = V2.w; for (var i = 0; i < N; i++) { if (V2w[i] < 0) { V2w[i] = 0; // threshold at 0 } } this.out_act = V2; return(this.out_act); }