public Vol Forward(Vol V, bool is_training) { is_training = false; this.input = V; var V2 = V.Clone(); var N = V.W.Length; if (is_training) { // do dropout for (var i = 0; i < N; i++) { if ((float)r.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] *= 0.5f; } } this.Output = V2; return(this.Output); // dummy identity function for now }
public 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.Output = V2; return(this.Output); }