Beispiel #1
0
            public Dictionary<object, object> predict(Dictionary<string, dynamic> inputData,
                                                      bool byName = true,
                                                      Combiner combiner = Combiner.Plurality,
                                                      int missing_strategy = 0,
                                                      bool addDistribution=true)
            {
                mv = new MultiVote();

                if (_models.Count > 1) {
                    inputData = _models[0].prepareInputData(inputData);
                }

                for (i = 0; i < this._models.Count; i++)
                {
                    _modelsPredictions[i] = this._models[i].predict(inputData, byName, missing_strategy);
                    mv.append(_modelsPredictions[i].toDictionary(addDistribution));
                }
                return mv.combine((int)combiner, addDistribution: addDistribution);
            }
Beispiel #2
0
        public static NeuralNetwork<Matrix> CreateConv(IDataSet<Matrix, Vector> dataSet)
        {
            var count  = 5;
            var branch = 5;

            var a = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                a[i] = new MatrixConvolutor(28, 28, 24, 24, new Tanh());

            var b = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                b[i] = new MatrixSubsampler(24, 24, 12, 12, new Tanh());

            var c = new ISingleLayer<Matrix, Matrix>[branch];
            for (var i = 0; i < branch; ++i)
                c[i] = new MatrixConvolutor(12, 12, 8, 8, new Tanh());

            var d = new ISingleLayer<Matrix, Matrix>[count * branch];
            for (var i = 0; i < count * branch; ++i)
                d[i] = new MatrixSubsampler(8, 8, 4, 4, new Tanh());

            var splitter    = new Splitter<Matrix, Matrix>(a);
            var applicator1 = new Applicator<Matrix, Matrix>(b);
            var applicator2 = new Combiner<Matrix, Matrix>(c, count);
            var merger      = new MatrixMerger<Matrix>(d);

            var classif  = new FullyConnectedLayer(16 * branch * count, 10, new Tanh());

            var comp = CompositeLayer<Vector, Vector[], Vector>.Compose(splitter,
                                                                        applicator1,
                                                                        applicator2,
                                                                        merger,
                                                                        classif);

            return new NeuralNetwork<Matrix>(comp);
        }
        private string CombineParamPairs(string xPath,
            string itemBreak, string charJoin, Combiner appender)
        {
            XmlNodeList children = Payload.SelectNodes(xPath, NSM);

            if (children.Count==0)
                return "";

            StringBuilder sb = new StringBuilder();

            foreach(XmlNode child in children)
            {
                sb.Append(appender(child,charJoin));
                sb.Append(itemBreak);
            }

            string output = sb.ToString();
            return output.Substring(0, output.Length - itemBreak.Length);
        }