Пример #1
0
        /// <summary>
        /// Builds the internal probabilistic cluster chain and makes the "One Takes All" group operable.
        /// </summary>
        /// <param name="readoutUnitsResultsCollection">The collection of the collections of all readout units composite results.</param>
        /// <param name="readoutUnitsIdealValuesCollection">The collection of the collections of all readout units ideal values.</param>
        /// <param name="filters">The feature filters to be used to denormalize output data.</param>
        /// <param name="rand">The random object to be used.</param>
        /// <param name="controller">The build process controller (optional).</param>
        public void Build(List <CompositeResult[]> readoutUnitsResultsCollection,
                          List <double[]> readoutUnitsIdealValuesCollection,
                          BinFeatureFilter[] filters,
                          Random rand,
                          TNRNetBuilder.BuildControllerDelegate controller = null
                          )
        {
            if (DecisionMethod != OneTakesAllDecisionMethod.ClusterChain)
            {
                throw new InvalidOperationException("Wrong call of the Build method.");
            }
            OneTakesAllClusterChainDecisionSettings decisionCfg = (OneTakesAllClusterChainDecisionSettings)_groupCfg.DecisionCfg;
            //Prepare the training data bundle for the cluster chain
            VectorBundle trainingDataBundle = new VectorBundle(readoutUnitsIdealValuesCollection.Count);

            for (int sampleIdx = 0; sampleIdx < readoutUnitsIdealValuesCollection.Count; sampleIdx++)
            {
                double[] inputVector  = CreateInputVector(readoutUnitsResultsCollection[sampleIdx]);
                double[] outputVector = CreateOutputVector(readoutUnitsIdealValuesCollection[sampleIdx], filters);
                trainingDataBundle.AddPair(inputVector, outputVector);
            }


            //Cluster chain builder
            TNRNetClusterChainBuilder builder = new TNRNetClusterChainBuilder(Name,
                                                                              decisionCfg.ClusterChainCfg,
                                                                              rand,
                                                                              controller
                                                                              );

            builder.ChainBuildProgressChanged += OnChainBuildProgressChanged;
            ProbabilisticClusterChain          = builder.Build(trainingDataBundle, filters);
            return;
        }
Пример #2
0
        private double[] CreateInputVector(CompositeResult[] allReadoutUnitResults)
        {
            OneTakesAllClusterChainDecisionSettings clusterCfg = (OneTakesAllClusterChainDecisionSettings)_groupCfg.DecisionCfg;
            List <double[]> components = new List <double[]>();

            foreach (int unitIdx in MemberReadoutUnitIndexCollection)
            {
                if (clusterCfg.UseReadoutUnitsFinalResult)
                {
                    components.Add(allReadoutUnitResults[unitIdx].Result);
                }
                if (clusterCfg.UseReadoutUnitsSubResults)
                {
                    foreach (double[] subResult in allReadoutUnitResults[unitIdx].SubResults)
                    {
                        components.Add(subResult);
                    }
                }
            }
            return(NonRecurrentNetUtils.Flattenize(components));
        }
 /// <summary>
 /// The copy constructor.
 /// </summary>
 /// <param name="source">The source instance.</param>
 public OneTakesAllClusterChainDecisionSettings(OneTakesAllClusterChainDecisionSettings source)
     : this(source.ClusterChainCfg, source.UseReadoutUnitsFinalResult, source.UseReadoutUnitsSubResults)
 {
     return;
 }