示例#1
0
        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
            //);
        }
示例#2
0
 private void SetBest(LayerHolder best)
 {
     lock (_bestLock)
     {
         if (best.Loss < _bestLoss)
         {
             _bestLearner = new KeyValuePair <Layer <TSample>, float[]>(best.Layer, best.Values);
             _bestLoss    = best.Loss;
         }
     }
 }
示例#3
0
        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);
        }
示例#4
0
 public LayerView(LayerHolder holder)
 {
     InitializeComponent();
     this.DataContext = holder;
     this.holder      = holder;
 }
示例#5
0
        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;
 }
示例#7
0
        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);
        }