Encog.Neural.Data.Buffer.EncogEGBFile.Create C# (CSharp) Method

Create() public method

Create a new RGB file.
public Create ( int inputCount, int idealCount ) : void
inputCount int The input count.
idealCount int The ideal count.
return void
        public void Create(int inputCount, int idealCount)
        {
            try
            {
                this.inputCount = inputCount;
                this.idealCount = idealCount;

                double[] input = new double[inputCount];
                double[] ideal = new double[idealCount];

                this.stream = new FileStream(this.file, FileMode.Create, FileAccess.ReadWrite);
                this.binaryWriter = new BinaryWriter(this.stream);
                this.binaryReader = null;

                this.binaryWriter.Write((byte)'E');
                this.binaryWriter.Write((byte)'N');
                this.binaryWriter.Write((byte)'C');
                this.binaryWriter.Write((byte)'O');
                this.binaryWriter.Write((byte)'G');
                this.binaryWriter.Write((byte)'-');
                this.binaryWriter.Write((byte)'0');
                this.binaryWriter.Write((byte)'0');

                this.binaryWriter.Write((double)input.Length);
                this.binaryWriter.Write((double)ideal.Length);

                this.numberOfRecords = 0;
                this.recordCount = this.inputCount + this.idealCount;
                this.recordSize = this.recordCount * EncogEGBFile.DOUBLE_SIZE;
            }
            catch (IOException ex)
            {
                throw new BufferedDataError(ex);
            }
        }

Usage Example

        /// <summary>
        /// Convert an external file format, such as CSV, to the Encog binary
        /// training format. 
        /// </summary>
        /// <param name="binaryFile">The binary file to create.</param>
        public void External2Binary(String binaryFile)
        {

            Status.Report(0, 0, "Importing to binary file: "
                    + binaryFile);

            EncogEGBFile egb = new EncogEGBFile(binaryFile);

            egb.Create(codec.InputSize, codec.IdealSize);

            double[] input = new double[this.codec.InputSize];
            double[] ideal = new double[this.codec.IdealSize];

            this.codec.PrepareRead();

            int index = 3;
            int currentRecord = 0;
            int lastUpdate = 0;

            while (codec.Read(input, ideal))
            {

                egb.Write(input);
                egb.Write(ideal);

                index += input.Length;
                index += ideal.Length;
                currentRecord++;
                lastUpdate++;
                if (lastUpdate >= 10000)
                {
                    lastUpdate = 0;
                    this.Status.Report(0, currentRecord, "Importing...");
                }
            }

            egb.Close();
            this.codec.Close();
            Status.Report(0, 0, "Done importing to binary file: "
                    + binaryFile);

        }
All Usage Examples Of Encog.Neural.Data.Buffer.EncogEGBFile::Create