public override Volume Forward(Volume input, bool isTraining = false) { this.InputActivation = input; var output = input.Clone(); var length = input.Weights.Length; if (isTraining) { // do dropout for (var i = 0; i < length; i++) { if (Random.NextDouble() < this.DropProb.Value) { output.Weights[i] = 0; this.dropped[i] = true; } // drop! else { this.dropped[i] = false; } } } else { // scale the activations during prediction for (var i = 0; i < length; i++) { output.Weights[i] *= this.DropProb.Value; } } this.OutputActivation = output; return this.OutputActivation; // dummy identity function for now }
public override Volume Forward(Volume input, bool isTraining = false) { this.InputActivation = input; var output = input.Clone(); var length = input.Weights.Length; if (isTraining) { // do dropout for (var i = 0; i < length; i++) { if (Random.NextDouble() < this.DropProb.Value) { output.Weights[i] = 0; this.dropped[i] = true; } // drop! else { this.dropped[i] = false; } } } else { // scale the activations during prediction for (var i = 0; i < length; i++) { output.Weights[i] *= this.DropProb.Value; } } this.OutputActivation = output; return(this.OutputActivation); // dummy identity function for now }
public override Volume Forward(Volume input, bool isTraining = false) { this.InputActivation = input; var output = input.Clone(); var length = input.Weights.Length; double[] outputWeights = output.Weights; #if PARALLEL Parallel.For(0, length, i => #else for (var i = 0; i < length; i++) #endif { if (outputWeights[i] < 0) { outputWeights[i] = 0; // threshold at 0 } }
public override Volume Forward(Volume input, bool isTraining = false) { this.InputActivation = input; var output = input.Clone(); var length = input.Weights.Length; double[] outputWeights = output.Weights; #if PARALLEL Parallel.For(0, length, i => #else for (var i = 0; i < length; i++) #endif { if (outputWeights[i] < 0) { outputWeights[i] = 0; // threshold at 0 } } #if PARALLEL ); #endif this.OutputActivation = output; return this.OutputActivation; }