Esempio n. 1
0
        public void SerializationTest()
        {
            // Create a DropOutLayer
            var layer = new DropOutLayer
            {
                DropProb = 0.5
            };

            layer.Init(10, 10, 3);

            DropOutLayer deserialized;

            using (var ms = new MemoryStream())
            {
                // Serialize
                IFormatter formatter = new BinaryFormatter();
                formatter.Serialize(ms, layer);

                // Deserialize
                ms.Position  = 0;
                deserialized = formatter.Deserialize(ms) as DropOutLayer;
            }


            Assert.AreEqual(layer.InputDepth, deserialized.InputDepth);
            Assert.AreEqual(layer.InputHeight, deserialized.InputHeight);
            Assert.AreEqual(layer.InputWidth, deserialized.InputWidth);
            Assert.AreEqual(layer.OutputDepth, deserialized.OutputDepth);
            Assert.AreEqual(layer.OutputHeight, deserialized.OutputHeight);
            Assert.AreEqual(layer.OutputWidth, deserialized.OutputWidth);
            Assert.AreEqual(layer.DropProb, deserialized.DropProb);
        }
Esempio n. 2
0
        public static DropOutLayer DropOut(this LayerBase layer, double prob = 0.5)
        {
            var dropout = new DropOutLayer(prob);

            layer.ConnectTo(dropout);

            return(dropout);
        }