Esempio n. 1
0
        public override void Load(BinaryReader reader)
        {
            string s;

            BinIO.string_read(reader, out s);
            if (s == "<object>")
            {
                // load lenet arguments
                int nclasses;
                BinIO.scalar_read(reader, out nclasses);
                lenetWrap.Classes = new int[nclasses];
                for (int i = 0; i < nclasses; i++)
                {
                    BinIO.scalar_read(reader, out lenetWrap.Classes[i]);
                }
                byte boolval;
                BinIO.scalar_read(reader, out boolval);
                lenetWrap.TanhSigmoid = Convert.ToBoolean(boolval);
                BinIO.scalar_read(reader, out boolval);
                lenetWrap.NetNorm = Convert.ToBoolean(boolval);
                BinIO.scalar_read(reader, out boolval);
                lenetWrap.AsciiTarget = Convert.ToBoolean(boolval);

                // load Narray from stream
                BinIO.narray_read(reader, lenetparam);
                double[] dbuffer = lenetparam.To1DArray();

                Global.Debugf("info", "loading " + Name + "..");

                // create lenet
                if (lenetWrap.IsEmpty)
                {
                    lenetWrap.CreateLenet(lenetWrap.Classes.Length, lenetWrap.Classes, lenetWrap.TanhSigmoid, lenetWrap.NetNorm, lenetWrap.AsciiTarget);
                }

                // send loaded buffer to created lenet
                lenetWrap.LoadNetworkFromBuffer(dbuffer, dbuffer.Length);
                BinIO.string_read(reader, out s);
                if (s != "</object>")
                {
                    throw new Exception("Expected string: </object>");
                }
            }
        }
Esempio n. 2
0
        public void LoadOldFormat(BinaryReader reader)
        {
            string magic = BinIO.magic_get(reader, "linerec".Length);

            CHECK_ARG(magic == "linerec" || magic == "linerc2", "magic=='linerec' || magic=='linerc2'");
            PLoad(reader);
            IComponent comp   = ComponentIO.load_component(reader);
            IModel     cmodel = comp as IModel;

            classifier.Object = cmodel;
            counts.Clear();
            if (magic == "linerec")
            {
                PSet("minsize_factor", 0.0);
            }
            else if (magic == "linerc2")
            {
                Narray <int> intcount = counts;
                BinIO.narray_read(reader, intcount);
            }
        }