Ocronet.Dynamic.IOData.RowDataset8.Add C# (CSharp) Method

Add() public method

public Add ( Floatarray v, int c ) : void
v Floatarray
c int
return void
        public override void Add(Floatarray v, int c)
        {
            CHECK_ARG(NarrayUtil.Min(v) >= 0.0f && NarrayUtil.Max(v) <= 1.0f, "float8: value out of range (0..1)");
            CHECK_ARG(c >= -1, "c>=-1");
            if (c >= nc) nc = c + 1;
            if (nf < 0) nf = v.Length();
            Narray<byte> newDataItem = data.Push(new Narray<byte>());
            Copy(newDataItem, v);
            classes.Push(c);
            CHECK_ARG(nc > 0, "nc>0");
            CHECK_ARG(nf > 0, "nf>0");
        }

Same methods

RowDataset8::Add ( Floatarray ds, Intarray cs ) : void

Usage Example

Exemplo n.º 1
0
        public static RowDataset8 GetRowDataset8(MnistDatasource mds, int[] classes)
        {
            if (mds.NSamples() == 0)
                throw new Exception("MNIST database is empty!");

            // определим максимальный индекс
            byte maxLabel = 0;
            foreach (byte label in mds.Labels)
            {
                if (label > maxLabel)
                    maxLabel = label;
            }

            // проверим соответствие индексов Mnist указанному списку классов
            if (maxLabel >= classes.Length)
                throw new Exception("Classes do not correspond to the MNIST!");

            // создаем тренировочную базу
            RowDataset8 ds = new RowDataset8(mds.NSamples());
            // перебираем MNIST базу
            for (int i = 0; i < mds.NSamples(); i++)
            {
                int label = mds.Labels[i];
                StdInput stdInp = new StdInput(mds.ImagesData[i], mds.ImgHeight, mds.ImgWidth);
                ds.Add(stdInp.ToFloatarray(), classes[label]);
            }
            return ds;
        }
All Usage Examples Of Ocronet.Dynamic.IOData.RowDataset8::Add