/// <summary> /// Start the job, block until its done. /// </summary> public virtual void Process() { _totalTasks = LoadWorkload(); if (ThreadCount == 1) { Object task; int currentTask = 0; while ((task = RequestNextTask()) != null) { currentTask++; var context = new JobUnitContext { JobUnit = task, Owner = this, TaskNumber = currentTask }; var worker = new JobUnitWorker(context); worker.Run(); } } else { Parallel.For(0, _totalTasks, currentTask => { Object task = RequestNextTask(); var context = new JobUnitContext { JobUnit = task, Owner = this, TaskNumber = currentTask }; var worker = new JobUnitWorker(context); worker.Run(); }); } }
/// <summary> /// Start the job, block until its done. /// </summary> public virtual void Process() { Object task; EngineConcurrency.Instance.ThreadCount = ThreadCount; TaskGroup group = EngineConcurrency.Instance.CreateTaskGroup(); _totalTasks = LoadWorkload(); int currentTask = 0; while ((task = RequestNextTask()) != null) { currentTask++; var context = new JobUnitContext { JobUnit = task, Owner = this, TaskNumber = currentTask }; var worker = new JobUnitWorker(context); EngineConcurrency.Instance.ProcessTask(worker, group); } group.WaitForComplete(); }
/// <summary> /// Perform the actual workload. /// </summary> /// <param name="context">The workload to execute.</param> public abstract void PerformJobUnit(JobUnitContext context);
/// <summary> /// Recieve status reports. /// </summary> /// <param name="context">The context for this job.</param> /// <param name="status">The current status for this job.</param> public void ReportStatus(JobUnitContext context, String status) { _report.Report(_totalTasks, context.TaskNumber, status, 0.0, 0.0); }
public JobUnitWorker(JobUnitContext context) { this._x0f7b23d1c393aed9 = context; }
/// <summary> /// Recieve status reports. /// </summary> /// <param name="context">The context for this job.</param> /// <param name="status">The current status for this job.</param> public void ReportStatus(JobUnitContext context, String status) { _report.Report(_totalTasks, context.TaskNumber, status); }
/// <summary> /// Perform an individual job unit, which is a single network to train and /// evaluate. /// </summary> /// /// <param name="context">Contains information about the job unit.</param> public override sealed void PerformJobUnit(JobUnitContext context) { var network = (BasicNetwork) context.JobUnit; BufferedMLDataSet buffer = null; IMLDataSet useTraining = _training; if (_training is BufferedMLDataSet) { buffer = (BufferedMLDataSet) _training; useTraining = (buffer.OpenAdditional()); } // train the neural network double error = Double.PositiveInfinity; for (int z = 0; z < _weightTries; z++) { network.Reset(); Propagation train = new ResilientPropagation(network, useTraining); var strat = new StopTrainingStrategy(0.001d, 5); train.AddStrategy(strat); train.ThreadCount = 1; // force single thread mode for (int i = 0; (i < _iterations) && !ShouldStop && !strat.ShouldStop(); i++) { train.Iteration(); } error = Math.Min(error, train.Error); } if (buffer != null) { buffer.Close(); } if (!ShouldStop) { // update min and max _high = Math.Max(_high, error); _low = Math.Min(_low, error); if (_hidden1Size > 0) { int networkHidden1Count; int networkHidden2Count; if (network.LayerCount > 3) { networkHidden2Count = network.GetLayerNeuronCount(2); networkHidden1Count = network.GetLayerNeuronCount(1); } else { networkHidden2Count = 0; networkHidden1Count = network.GetLayerNeuronCount(1); } int row, col; if (_hidden2Size == 0) { row = networkHidden1Count - _hidden[0].Min; col = 0; } else { row = networkHidden1Count - _hidden[0].Min; col = networkHidden2Count - _hidden[1].Min; } if ((row < 0) || (col < 0)) { Console.Out.WriteLine("STOP"); } _results[row][col] = error; } // report status _currentTry++; UpdateBest(network, error); ReportStatus( context, "Current: " + NetworkToString(network) + "; Best: " + NetworkToString(_bestNetwork)); } }
/// <summary> /// Start the job, block until its done. /// </summary> public virtual void Process() { Object task; TaskGroup group = EngineConcurrency.Instance.CreateTaskGroup(); _totalTasks = LoadWorkload(); int currentTask = 0; while ((task = RequestNextTask()) != null) { currentTask++; var context = new JobUnitContext {JobUnit = task, Owner = this, TaskNumber = currentTask}; var worker = new JobUnitWorker(context); EngineConcurrency.Instance.ProcessTask(worker, group); } group.WaitForComplete(); }
public virtual void Process() { object obj2; TaskGroup group; int num; JobUnitContext context; JobUnitContext context2; EngineConcurrency.Instance.ThreadCount = this.ThreadCount; if (0 == 0) { group = EngineConcurrency.Instance.CreateTaskGroup(); this._x5cd5268c7a8f6ac5 = this.LoadWorkload(); num = 0; } Label_0015: while ((obj2 = this.RequestNextTask()) != null) { num++; context2 = new JobUnitContext { JobUnit = obj2, Owner = this }; if ((((uint) num) - ((uint) num)) > uint.MaxValue) { goto Label_0032; } if (0x7fffffff != 0) { context2.TaskNumber = num; goto Label_0032; } } group.WaitForComplete(); return; Label_0032: context = context2; JobUnitWorker task = new JobUnitWorker(context); EngineConcurrency.Instance.ProcessTask(task, group); goto Label_0015; }
public void ReportStatus(JobUnitContext context, string status) { this._x64343a0786fb9a3f.Report(this._x5cd5268c7a8f6ac5, context.TaskNumber, status); }
public override sealed void PerformJobUnit(JobUnitContext context) { double num; int num2; int num3; int num4; int layerNeuronCount; int num6; int num7; BasicNetwork jobUnit = (BasicNetwork) context.JobUnit; BufferedMLDataSet set = null; IMLDataSet training = this._x823a2b9c8bf459c5; if (this._x823a2b9c8bf459c5 is BufferedMLDataSet) { set = (BufferedMLDataSet) this._x823a2b9c8bf459c5; if ((((uint) num) + ((uint) num2)) > uint.MaxValue) { goto Label_02BB; } } else { if (((uint) num4) > uint.MaxValue) { goto Label_0302; } goto Label_02BB; } training = set.OpenAdditional(); goto Label_0302; Label_0011: this._x7ca40c9a68f86359++; this.x6aa420caefd31103(jobUnit, num); base.ReportStatus(context, "Current: " + NetworkToString(jobUnit) + "; Best: " + NetworkToString(this._x61bb83c40eed7f47)); if (((uint) num) >= 0) { return; } if (((uint) layerNeuronCount) <= uint.MaxValue) { goto Label_0104; } if ((((uint) layerNeuronCount) | 3) == 0) { } Label_0090: if (num6 >= 0) { if (num7 >= 0) { goto Label_00A7; } } else if (0 != 0) { goto Label_00B9; } Console.Out.WriteLine("STOP"); Label_00A7: this._xd559aa34776631a5[num6][num7] = num; goto Label_0011; Label_00B9: if (this._xe4e6a25eae13e4b3 > 0) { goto Label_0188; } if (0 == 0) { if ((((uint) num3) & 0) != 0) { return; } goto Label_0011; } Label_0104: num7 = 0; goto Label_0090; Label_0125: num4 = jobUnit.GetLayerNeuronCount(1); Label_012E: if (this._x5426aa354995e9e0 != 0) { num6 = num4 - this._xab3ddaff42dd298a[0].Min; num7 = layerNeuronCount - this._xab3ddaff42dd298a[1].Min; goto Label_0090; } num6 = num4 - this._xab3ddaff42dd298a[0].Min; if ((((uint) num3) | 0xfffffffe) != 0) { goto Label_0104; } return; Label_0188: if (jobUnit.LayerCount <= 3) { layerNeuronCount = 0; goto Label_0125; } layerNeuronCount = jobUnit.GetLayerNeuronCount(2); num4 = jobUnit.GetLayerNeuronCount(1); goto Label_012E; Label_0195: if (base.ShouldStop) { return; } this._x628ea9b89457a2a9 = Math.Max(this._x628ea9b89457a2a9, num); this._xd12d1dba8a023d95 = Math.Min(this._xd12d1dba8a023d95, num); if ((((uint) num2) + ((uint) num6)) <= uint.MaxValue) { goto Label_00B9; } goto Label_0188; Label_02BB: num = double.PositiveInfinity; num2 = 0; Label_0217: if (num2 < this._xe009ad1bd0a8245a) { StopTrainingStrategy strategy; jobUnit.Reset(); Encog.Neural.Networks.Training.Propagation.Propagation propagation = new ResilientPropagation(jobUnit, training); if ((((uint) num) - ((uint) num3)) >= 0) { strategy = new StopTrainingStrategy(0.001, 5); } propagation.AddStrategy(strategy); propagation.ThreadCount = 1; num3 = 0; while (true) { if ((num3 < this._xdbf51c857aeb8093) && (!base.ShouldStop && !strategy.ShouldStop())) { propagation.Iteration(); } else { num = Math.Min(num, propagation.Error); if (4 != 0) { num2++; goto Label_0217; } goto Label_0195; } num3++; } } while (set != null) { set.Close(); if (((uint) num4) <= uint.MaxValue) { break; } } goto Label_0195; Label_0302: if ((((uint) num4) - ((uint) layerNeuronCount)) < 0) { goto Label_0125; } goto Label_02BB; }