Exemplo n.º 1
0
        public float[] GetValues(FilterParameters frame)
        {
            // training
            trainingRuns++;

            if (trainingRuns < 10000)
            {
                float target = trainingFilter.GetValues(frame)[(int)BroadbandTransientFilter.Outputs.Edge];
                if (target < 0.95f)
                {
                    target = 0f;
                }
                output[(int)Outputs.TrainingTarget] = target;
                neuralNetwork.LearningRate          = target > 0.5f ? 0.05f : 0.01f;
                avgError = avgError * 0.99f + 0.01f * TrainNetwork(trainingContext, frame.SpectrumDB, target);
                output[(int)Outputs.Error] = avgError * 4.0f;
            }
            else
            {
                output[(int)Outputs.TrainingTarget] = 0.5f;
                output[(int)Outputs.Error]          = 0f;
            }

            // fill context with current spectrum frame
            runContext.Set(frame.SpectrumDB.Take(runContext.InputCount));

            neuralNetwork.Run(runContext);

            output[(int)Outputs.Output] = runContext.Outputs.First();
            return(output);
        }
Exemplo n.º 2
0
 private float TrainNetwork(INetworkRunContext context, IEnumerable <float> inputs, float target)
 {
     context.Set(inputs.Take(context.InputCount));
     context.Target[0] = target;
     neuralNetwork.Train(context);
     neuralNetwork.Update();
     return(context.TotalError);
 }