예제 #1
0
        // return the expected number of incoming messages
        // negative for any number.
        //		public abstract int NumInputMessages();

        // Load a FeatureMap in Matlab represented by the input
        // All FeatureMap objects can be serialized to struct with .toStruct()
        public static VectorMapper FromMatlabStruct(MatlabStruct s)
        {
            string       className = s.GetString("className");
            VectorMapper map       = null;

            if (className.Equals("RandFourierGaussMVMap"))
            {
                map = RFGMVMap.FromMatlabStruct(s);
            }
            else if (className.Equals("CondFMFiniteOut"))
            {
                map = CondFMFiniteOut.FromMatlabStruct(s);
            }
//			else if(className.Equals("CondCholFiniteOut")){
//				map = CondCholFiniteOut.FromMatlabStruct(s);
//			}
            else if (className.Equals(RFGJointKGG.MATLAB_CLASS))
            {
                map = RFGJointKGG.FromMatlabStruct(s);
            }
            else if (className.Equals(StackVectorMapper.MATLAB_CLASS))
            {
                map = StackVectorMapper.FromMatlabStruct(s);
            }
            else if (className.Equals(BayesLinRegFM.MATLAB_CLASS))
            {
                map = BayesLinRegFM.FromMatlabStruct(s);
            }
            else if (className.Equals(UAwareVectorMapper.MATLAB_CLASS))
            {
                map = UAwareVectorMapper.FromMatlabStruct(s);
            }
            else if (className.Equals(UAwareStackVectorMapper.MATLAB_CLASS))
            {
                map = UAwareStackVectorMapper.FromMatlabStruct(s);
            }
            else
            {
                throw new ArgumentException("Unknown className: " + className);
            }
            //			else if(className.Equals("RFGSumEProdMap")){
            //
            //			}else if(className.Equals("RFGEProdMap")){
            //
            //			}else if(className.Equals("RFGJointEProdMap")){
            //
            //			}else if(className.Equals("RFGProductEProdMap")){
            //
            //			}
            return(map);
        }
예제 #2
0
        public new static RFGJointKGG FromMatlabStruct(MatlabStruct s)
        {
            //			s.className=class(this);
            //			s.embed_width2s_cell = this.embed_width2s_cell;
            //			s.outer_width2 = this.outer_width2;
            //			s.numFeatures=this.numFeatures;
            //			s.innerNumFeatures = this.innerNumFeatures;
            //			s.eprodMap=this.eprodMap.toStruct();
            //			s.Wout = this.Wout;
            //			s.Bout = this.Bout;

            string className = s.GetString("className");

            if (!className.Equals(MATLAB_CLASS))
            {
                throw new ArgumentException("The input does not represent a " + MATLAB_CLASS);
            }

            double       outer_width2     = s.GetDouble("outer_width2");
            int          numFeatures      = s.GetInt("numFeatures");
            int          innerNumFeatures = s.GetInt("innerNumFeatures");
            MatlabStruct mapStruct        = s.GetStruct("eprodMap");
            RFGEProdMap  eprodMap         = RFGEProdMap.FromMatlabStruct(mapStruct);
            Matrix       Wout             = s.GetMatrix("Wout");

            if (innerNumFeatures != Wout.Rows)
            {
                throw new ArgumentException("inner #features must be  = #rows of Wout");
            }
            if (numFeatures != Wout.Cols)
            {
                throw new ArgumentException("numFeatures must be = #cols of Wout");
            }
            Vector Bout = s.Get1DVector("Bout");

            if (Bout.Count != numFeatures)
            {
                throw new ArgumentException("Bout must have length = numFeatures");
            }
            RFGJointKGG jointMap = new RFGJointKGG();

            jointMap.outer_width2     = outer_width2;
            jointMap.numFeatures      = numFeatures;
            jointMap.innerNumFeatures = innerNumFeatures;
            jointMap.eprodMap         = eprodMap;
            jointMap.Wout             = Wout;
            jointMap.Bout             = Bout;
            // construct object
            return(jointMap);
        }
예제 #3
0
        public override List <RandomFeatureMap> GenCandidates(List <IKEPDist[]> msgs,
                                                              int[] numFeatures, double[] medianFactors, Random rng)
        {
            // generate only one candidate for now
            RFGJointKGG             jointKgg    = RFGJointKGG.EmptyMap();
            List <RandomFeatureMap> canJointKgg = jointKgg.GenCandidates(msgs, numFeatures, medianFactors,
                                                                         rng);

            RandomFeatureMap[]      maps     = canJointKgg.ToArray();
            List <RandomFeatureMap> canStack = new List <RandomFeatureMap>();

            canStack.Add(new StackFeatureMap(maps));
            return(canStack);
        }
예제 #4
0
        public static RandomFeatureMap FromMatlabStruct(MatlabStruct s)
        {
            string           className = s.GetString("className");
            RandomFeatureMap map       = null;

            if (className.Equals(RFGJointKGG.MATLAB_CLASS))
            {
                map = RFGJointKGG.FromMatlabStruct(s);
            }
            else
            {
                throw new ArgumentException("Unknown className: " + className);
            }
            //			else if(className.Equals("RFGSumEProdMap")){
            //
            //			}else if(className.Equals("RFGEProdMap")){
            //
            //			}else if(className.Equals("RFGJointEProdMap")){
            //
            //			}else if(className.Equals("RFGProductEProdMap")){
            //
            //			}
            return(map);
        }