Exemplo n.º 1
0
        public void Serialize(NeuralLayeredNetwork network, Stream stream)
        {
            var             data      = network.GetNetworkInfo();
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(stream, data);
        }
Exemplo n.º 2
0
        public void Serialize(NeuralLayeredNetwork network, Stream stream)
        {
            var data = network.GetNetworkInfo();

            using TextWriter writer = new StreamWriter(stream);
            var options = new JsonSerializerOptions
            {
                Converters    = { new LayerInfoConverter() },
                WriteIndented = true
            };
            var json = JsonSerializer.Serialize(data, options);

            writer.Write(json);
        }
Exemplo n.º 3
0
        public void Serialize(NeuralLayeredNetwork network, string filePath)
        {
            FileInfo file = new FileInfo(filePath);

            if (file.Extension != ".cnn")
            {
                throw new ArgumentException($"File {filePath} has wrong format");
            }

            var             data      = network.GetNetworkInfo();
            BinaryFormatter formatter = new BinaryFormatter();

            using var stream = new FileStream(filePath, FileMode.OpenOrCreate);
            formatter.Serialize(stream, data);
        }