// Start is called before the first frame update void Start() { instance = this; net = new NeuralNetwork(numInput, numHidden, numOutput); errorEpoch = new float[2]; totalEpoch = 0; }
public static void Serialize(FileStream stream, NeuralNetworkImage image) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } byte[] buffer; // 1: new version signal buffer = BitConverter.GetBytes(SectionType.SECTION_START_SIGNAL); // 2-bytes stream.Write(buffer, 0, buffer.Length); // 2: serialize section type buffer = new byte[] { SECTION_TYPE }; // 1-bytes stream.Write(buffer, 0, buffer.Length); // 3: serialize version buffer = BitConverter.GetBytes(VERSION); // 2-bytes stream.Write(buffer, 0, buffer.Length); // 2: serializer layers LayerSerializer.Serialize(stream, image.layers); // functions serializer var function = new FunctionSerializerCore(stream); // 3: serialize error function function.Serialize(image.error_fnc); // 4: serialize regularization function function.Serialize(image.regularization); // 5: serialize data input convertor function.Serialize(image.input_convertor); // 6: serialize data output convertor function.Serialize(image.output_convertor); }
public static void Serialize(string path, NeuralNetworkImage image) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } using var stream = File.Create(path); stream.Flush(); // serialize file signature stream.Write(Encoding.ASCII.GetBytes(FILE_TYPE_SIGNATURE_STRING)); // end of file signature stream.Write(new byte[1], 0, 1); Serialize(stream, image); }