private void BestConfiguration(ILearner <TSample> learner) { var predictions = _cache.ContainsKey(learner.UniqueId) ? _cache[learner.UniqueId] : (_cache[learner.UniqueId] = GetPredictions(learner)); var best = new LayerHolder(float.PositiveInfinity, null, null); var sampleCount = predictions.Count; var samplesProcessed = 0; foreach (var p in predictions) { best = BestLayerSetup(learner.WithConfiguration(p.Key), p.Value, best); SetBest(best); if (_cancellation.IsCancellationRequested) { return; } if (_progress != null) { samplesProcessed++; _progress.Report(Tuple.Create("Finding best setup for \"" + learner.UniqueId + "\"", samplesProcessed * 100 / sampleCount)); } } //Parallel.ForEach( // predictions, // () => new LayerHolder(float.PositiveInfinity, null, null), // (p, s, best) => BestLayerSetup(learner.WithConfiguration(p.Key), p.Value, best), // SetBest //); }
private void SetBest(LayerHolder best) { lock (_bestLock) { if (best.Loss < _bestLoss) { _bestLearner = new KeyValuePair <Layer <TSample>, float[]>(best.Layer, best.Values); _bestLoss = best.Loss; } } }
internal override IntPtr _InternalGetConstPointer() { #if RHINO_SDK if (m_doc != null) { return(UnsafeNativeMethods.CRhinoLayerTable_GetLayerPointer2(m_doc.m_docId, m_id)); } #endif if (m_onx_model != null) { IntPtr pModel = m_onx_model.NonConstPointer(); return(UnsafeNativeMethods.ONX_Model_GetLayerPointer(pModel, m_id)); } if (m__parent is LayerHolder) { LayerHolder holder = m__parent as LayerHolder; return(holder.ConstPointer()); } return(IntPtr.Zero); }
public LayerView(LayerHolder holder) { InitializeComponent(); this.DataContext = holder; this.holder = holder; }
internal Layer(IntPtr pConstLayer) { LayerHolder holder = new LayerHolder(pConstLayer); ConstructConstObject(holder, -1); }
internal void SetPage(dlgDrawings page) { _page = page; _holder = new LayerHolder(page); propertyGrid2.SelectedObject = _holder; }
private LayerHolder BestLayerSetup(ILearner <TSample> learner, float[] predictions, LayerHolder best) { var result = OptimizeCoefficients(learner, predictions); #if DEBUG if (float.IsInfinity(result.Loss)) { // ReSharper disable once EmptyStatement ;//let me know } #endif best = result.Loss < best.Loss ? result : best; return(best); }