Esempio n. 1
0
        private static long[] AddCnnLayer(IAllocator allocator, SeedSource seedSource, DType elementType, Sequential model, long[] inputSizes, int nOutputPlane, bool useCudnn)
        {
            var conv = LayerBuilder.BuildConvLayer(allocator, seedSource, elementType, (int)inputSizes[0], (int)inputSizes[3], (int)inputSizes[2], (int)inputSizes[1], nOutputPlane,
                                                   new ConvolutionDesc2d(5, 5, 1, 1, 0, 0), useCudnn);

            model.Add(conv);

            var cdPool    = new ConvolutionDesc2d(2, 2, 1, 1, 0, 0);
            var poolLayer = LayerBuilder.BuildPoolLayer(allocator, elementType, conv.OutputSizes, cdPool, useCudnn);

            model.Add(poolLayer);

            model.Add(new ReLULayer(allocator, elementType, poolLayer.OutputSizes));

            return(poolLayer.OutputSizes);
        }