예제 #1
0
파일: Generator.cs 프로젝트: quider/neuron
        public ConvolutionalNetwork Create(ConvolutionalTopology topology)
        {
            Utility.Verify(topology,t => t!=null,"Invalid network topology");

            var l=topology.Layers.Length;
            Link[][] layers=new Link[l][];
            Bias bias=null;
            if(topology.Bias.HasValue)
                bias=new Bias(topology.Bias.Value);
            for(var i=0; i<l-1;i++){
                if(i==0)
                    layers[i]=Utility.Generate<Link>(topology.Layers[i]).ToArray();
                int j=i+1;
                int size=topology.Layers[j];
                if(topology.Map[i] is SubSampling)
                    layers[j]= Utility.Generate<SubSamplingNeuron>(size).ToArray();
                else
                    layers[j]= Utility.Generate<Neuron>(size).ToArray();

                topology.Map[i].Connect(layers[i],(NeuronBase[])layers[j],bias);
            }
            SetIdentity(layers);
            foreach(Link[] layer in layers)
                foreach(Link link in layer)
                    if(link is NeuronBase)
                        ((NeuronBase)link).Func=topology.Func;
            return new ConvolutionalNetwork(new NetworkStructure(layers,bias));
        }
예제 #2
0
파일: Form1.cs 프로젝트: quider/neuron
 void BuildNetwork()
 {
     int[] layers=new int[] {
         841,1014,1250,100,10
     };
     LayerConnector[] map=new LayerConnector[] {
         new ConvolutionAuto(5,6,1,3),
         new ConvolutionAuto(5,50,6,1),
         new FullLayerConnector(),
         new FullLayerConnector()
     };
     ConvolutionalTopology topology=new ConvolutionalTopology(layers,1,map,new HyperbolicTangent());
     ConvolutionalGenerator generator=new ConvolutionalGenerator();
     Network=generator.Create(topology);
     Network.LearnFactor=0.0005;
     Network.Reset(-0.1,0.1);
 }
예제 #3
0
        public ConvolutionalNetwork Create(ConvolutionalTopology topology)
        {
            Utility.Verify(topology, t => t != null, "Invalid network topology");

            var l = topology.Layers.Length;

            Link[][] layers = new Link[l][];
            Bias     bias   = null;

            if (topology.Bias.HasValue)
            {
                bias = new Bias(topology.Bias.Value);
            }
            for (var i = 0; i < l - 1; i++)
            {
                if (i == 0)
                {
                    layers[i] = Utility.Generate <Link>(topology.Layers[i]).ToArray();
                }
                int j    = i + 1;
                int size = topology.Layers[j];
                if (topology.Map[i] is SubSampling)
                {
                    layers[j] = Utility.Generate <SubSamplingNeuron>(size).ToArray();
                }
                else
                {
                    layers[j] = Utility.Generate <Neuron>(size).ToArray();
                }

                topology.Map[i].Connect(layers[i], (NeuronBase[])layers[j], bias);
            }
            SetIdentity(layers);
            foreach (Link[] layer in layers)
            {
                foreach (Link link in layer)
                {
                    if (link is NeuronBase)
                    {
                        ((NeuronBase)link).Func = topology.Func;
                    }
                }
            }
            return(new ConvolutionalNetwork(new NetworkStructure(layers, bias)));
        }
예제 #4
0
 public void TSSetUp()
 {
     int[] layers=new int[] {
         1024, //32x32 input image
         4704, //6 @ 28x28 convolution
         1176, //6 @  14x14 subsampling
         1600, //16 @ 10x10 convolution
         400, //16 @ 5x5 subsampling
         120, // 120x1x1 convolution!
         84, //full
         10 //full
     };
     LayerConnector[] map=new LayerConnector[] {
         new ConvolutionAuto(5,6,1,4),
         new SubSampling(6),
         new Convolution(5,16,6,4,GetSchema()),
         new SubSampling(16),
         new ConvolutionAuto(5,120,16,0),
         new FullLayerConnector(),
         new FullLayerConnector()
     };
     ConvolutionalTopology topology=new ConvolutionalTopology(layers,1,map);
     ConvolutionalGenerator generator=new ConvolutionalGenerator();
     Network=generator.Create(topology);
 }