示例#1
0
        public static NNModelMSN Create(string fileName)
        {
            List<InputTransform> inputList = new List<InputTransform>();
            List<NodeLayer> layerList = new List<NodeLayer>();
            List<Node> nodeList = new List<Node>();
            NNModelMSN nnMSN = null;

            DataSection[] dataSec = IniFile.Parse(fileName);
            for (int i = 0; i < dataSec.Length; i++)
            {
                if (InputTransform.IsType(dataSec[i]))
                {
                    inputList.Add(new InputTransform(dataSec[i]));
                }
                else if (NodeLayer.IsType(dataSec[i]))
                {
                    layerList.Add(new NodeLayer(dataSec[i]));
                }
                else if(Node.IsType(dataSec[i]))
                {
                    nodeList.Add(new Node(dataSec[i]));
                }
                else if (NNModelMSN.IsType(dataSec[i]))
                {
                    nnMSN = new NNModelMSN(dataSec[i]);
                }
            }

            if (nnMSN != null)
            {
                nnMSN.Init(inputList, layerList, nodeList);
            }

            return nnMSN;
        }
示例#2
0
        public NNModelMSN CovertToNNModelMSN(int cIter, bool fConvThresh2Int)
        {
            NNModelMSN sMartMSN = null;
            NNModelMSN subModelMSN = (NNModelMSN)this.SubModel;

            DTNode[,][] dtNodes = this.CreateDTNodes(this.FeatureNames, cIter);

            foreach (DTNode[] nodes in dtNodes)
            {
                foreach (DTNode node in nodes)
                {
                    if (node != null)
                    {
                        node.IsThresholdInt = fConvThresh2Int;
                    }
                }
            }

            sMartMSN = new NNModelMSN(subModelMSN, dtNodes);


            return sMartMSN;
        }
示例#3
0
        public NNModelMSN(NNModelMSN subModel, DTNode[,][] boostedDTs)
        {
            int cIter = boostedDTs.GetLength(0);
            int cClass = boostedDTs.GetLength(1);
            if (cClass == 1)
            {
                if (subModel != null)
                {
                    this.cNodeLayer = subModel.cNodeLayer;
                    this.cInputs = subModel.cInputs + cIter;

                    this.layers = new Layer[this.cNodeLayer + 1];

                    //create the input layer
                    this.layers[0] = new InputLayer((InputLayer)subModel.layers[0], boostedDTs, cIter);

                    //create the extended node layers
                    for (int l = 1; l <= this.cNodeLayer; l++)
                    {
                        this.layers[l] = new NodeLayer((NodeLayer)subModel.layers[l], this.layers[l - 1]);
                    }
                }
                else
                {
                    this.cNodeLayer = 1;
                    this.cInputs = cIter;
                    this.layers = new Layer[this.cNodeLayer + 1];

                    this.layers[0] = new InputLayer(boostedDTs, cIter);
                    this.layers[1] = new NodeLayer(1, this.cInputs, 1);

                }

                //add a new layer if necessary
                if (this.layers[this.cNodeLayer].cOutputs > 1)
                {
                    this.cNodeLayer++;
                    Layer[] layers = new Layer[this.cNodeLayer];
                    for (int i = 0; i < this.layers.Length; i++)
                    {
                        layers[i] = this.layers[i];
                    }
                    this.layers = layers;
                    this.layers[this.cNodeLayer-1] = new NodeLayer(this.cNodeLayer, this.layers[this.cNodeLayer-2].cOutputs, 1);
                }
            }
            else
            {
                if (subModel == null)
                {
                    this.cNodeLayer = 2;
                    this.cInputs = cIter * cClass;
                    this.layers = new Layer[this.cNodeLayer + 1];

                    this.layers[0] = new InputLayer(boostedDTs, cIter);
                    this.layers[1] = new NodeLayer(1, this.cInputs, cClass);//multiplex layer
                    this.layers[2] = new NodeLayer(2, cClass); //dotproduct node layer
                }
                else
                {
                    throw new Exception("Multiclass sub-mart has not been implemented yet");
                }
            }
        }