Ejemplo n.º 1
0
        protected virtual void GetLinesOfPage(Intarray lines, int ipage)
        {
            lines.Clear();
            string     dirName  = String.Format("{0}{1}{2:0000}", prefix, Path.DirectorySeparatorChar, ipage);
            DirPattern dpattern = new DirPattern(dirName, @"([0-9][0-9][0-9][0-9])\.png");

            if (dpattern.Length > 0)
            {
                lines.ReserveTo(dpattern.Length);
            }
            List <int> llist = new List <int>(dpattern.Length);

            for (int i = 0; i < dpattern.Length; i++)
            {
                int k = int.Parse(dpattern[i]);
                llist.Add(k);
                //lines.Push(k);
            }
            IEnumerable <int> query = llist.OrderBy(i => i);

            foreach (int iline in query)
            {
                lines.Push(iline);
            }
        }
Ejemplo n.º 2
0
        protected override void Train(IDataset ds)
        {
            if (!(ds.nSamples() > 0))
            {
                throw new Exception("nSamples of IDataset must be > 0");
            }
            if (!(ds.nFeatures() > 0))
            {
                throw new Exception("nFeatures of IDataset must be > 0");
            }
            if (c2i.Length() < 1)
            {
                Intarray raw_classes = new Intarray();
                raw_classes.ReserveTo(ds.nSamples());
                for (int i = 0; i < ds.nSamples(); i++)
                {
                    raw_classes.Push(ds.Cls(i));
                }
                ClassMap(c2i, i2c, raw_classes);

                /*Intarray classes = new Intarray();
                 * ctranslate(classes, raw_classes, c2i);*/
                //debugf("info","[mapped %d to %d classes]\n",c2i.length(),i2c.length());
            }
            TranslatedDataset mds = new TranslatedDataset(ds, c2i);

            TrainDense(mds);
        }
Ejemplo n.º 3
0
 public RowDataset8(int nsamples)
 {
     DatatypeSize = sizeof(byte);   // one byte
     data = new ObjList<Narray<byte>>();
     data.ReserveTo(nsamples);
     classes = new Intarray();
     classes.ReserveTo(nsamples);
     nc = -1;
     nf = -1;
 }
Ejemplo n.º 4
0
 public RowDataset8(int nsamples)
 {
     DatatypeSize = sizeof(byte);   // one byte
     data         = new ObjList <Narray <byte> >();
     data.ReserveTo(nsamples);
     classes = new Intarray();
     classes.ReserveTo(nsamples);
     nc = -1;
     nf = -1;
 }
Ejemplo n.º 5
0
 protected override void GetLinesOfPage(Intarray lines, int ipage)
 {
     lines.Clear();
     string dirName = String.Format("{0}{1}{2:0000}", prefix, Path.DirectorySeparatorChar, ipage);
     //DirPattern dpattern = new DirPattern(dirName, @"([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\.png");
     DirPattern dpattern = new DirPattern(dirName, @"([0-9][0-9][0-9][0-9][0-9][0-9])\.png");
     if (dpattern.Length > 0)
         lines.ReserveTo(dpattern.Length);
     for (int i = 0; i < dpattern.Length; i++)
     {
         int k = int.Parse(dpattern[i]);
         lines.Push(k);
     }
 }
Ejemplo n.º 6
0
        protected override void GetLinesOfPage(Intarray lines, int ipage)
        {
            lines.Clear();
            string dirName = String.Format("{0}{1}{2:0000}", prefix, Path.DirectorySeparatorChar, ipage);
            //DirPattern dpattern = new DirPattern(dirName, @"([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\.png");
            DirPattern dpattern = new DirPattern(dirName, @"([0-9][0-9][0-9][0-9][0-9][0-9])\.png");

            if (dpattern.Length > 0)
            {
                lines.ReserveTo(dpattern.Length);
            }
            for (int i = 0; i < dpattern.Length; i++)
            {
                int k = int.Parse(dpattern[i]);
                lines.Push(k);
            }
        }
Ejemplo n.º 7
0
 protected override void Train(IDataset ds)
 {
     if (!(ds.nSamples() > 0))
         throw new Exception("nSamples of IDataset must be > 0");
     if (!(ds.nFeatures() > 0))
         throw new Exception("nFeatures of IDataset must be > 0");
     if (c2i.Length() < 1)
     {
         Intarray raw_classes = new Intarray();
         raw_classes.ReserveTo(ds.nSamples());
         for (int i = 0; i < ds.nSamples(); i++)
             raw_classes.Push(ds.Cls(i));
         ClassMap(c2i, i2c, raw_classes);
         /*Intarray classes = new Intarray();
         ctranslate(classes, raw_classes, c2i);*/
         //debugf("info","[mapped %d to %d classes]\n",c2i.length(),i2c.length());
     }
     TranslatedDataset mds = new TranslatedDataset(ds, c2i);
     TrainDense(mds);
 }
Ejemplo n.º 8
0
 protected virtual void GetLinesOfPage(Intarray lines, int ipage)
 {
     lines.Clear();
     string dirName = String.Format("{0}{1}{2:0000}", prefix, Path.DirectorySeparatorChar, ipage);
     DirPattern dpattern = new DirPattern(dirName, @"([0-9][0-9][0-9][0-9])\.png");
     if (dpattern.Length > 0)
         lines.ReserveTo(dpattern.Length);
     List<int> llist = new List<int>(dpattern.Length);
     for (int i = 0; i < dpattern.Length; i++)
     {
         int k = int.Parse(dpattern[i]);
         llist.Add(k);
         //lines.Push(k);
     }
     IEnumerable<int> query = llist.OrderBy(i => i);
     foreach (int iline in query)
         lines.Push(iline);
 }