Пример #1
0
        private static Layer parse_connected(KeyValuePair[] options, SizeParams parameters)
        {
            int        output         = OptionList.option_find_int(options, "output", 1);
            string     activationS    = OptionList.option_find_str(options, "activation", "logistic");
            Activation activation     = ActivationsHelper.Get_activation(activationS);
            bool       batchNormalize = OptionList.option_find_int_quiet(options, "batch_normalize", 0) != 0;

            return(Layer.make_connected_layer(parameters.Batch, parameters.Inputs, output, activation, batchNormalize));
        }
Пример #2
0
        private static Layer parse_crnn(KeyValuePair[] options, SizeParams parameters)
        {
            int        outputFilters  = OptionList.option_find_int(options, "output_filters", 1);
            int        hiddenFilters  = OptionList.option_find_int(options, "hidden_filters", 1);
            string     activationS    = OptionList.option_find_str(options, "activation", "logistic");
            Activation activation     = ActivationsHelper.Get_activation(activationS);
            bool       batchNormalize = OptionList.option_find_int_quiet(options, "batch_normalize", 0) != 0;

            Layer l = Layer.make_crnn_layer(parameters.Batch, parameters.W, parameters.H, parameters.C, hiddenFilters, outputFilters, parameters.TimeSteps, activation, batchNormalize);

            l.Shortcut = OptionList.option_find_int_quiet(options, "shortcut", 0) != 0;

            return(l);
        }
Пример #3
0
        private static Layer parse_activation(KeyValuePair[] options, SizeParams parameters)
        {
            string     activationS = OptionList.option_find_str(options, "activation", "linear");
            Activation activation  = ActivationsHelper.Get_activation(activationS);

            Layer l = Layer.make_activation_layer(parameters.Batch, parameters.Inputs, activation);

            l.OutH = parameters.H;
            l.OutW = parameters.W;
            l.OutC = parameters.C;
            l.H    = parameters.H;
            l.W    = parameters.W;
            l.C    = parameters.C;

            return(l);
        }
Пример #4
0
        private static Layer parse_convolutional(KeyValuePair[] options, SizeParams parameters)
        {
            int n       = OptionList.option_find_int(options, "filters", 1);
            int size    = OptionList.option_find_int(options, "size", 1);
            int stride  = OptionList.option_find_int(options, "stride", 1);
            int pad     = OptionList.option_find_int_quiet(options, "pad", 0);
            int padding = OptionList.option_find_int_quiet(options, "padding", 0);

            if (pad != 0)
            {
                padding = size / 2;
            }

            string     activationS = OptionList.option_find_str(options, "activation", "logistic");
            Activation activation  = ActivationsHelper.Get_activation(activationS);

            int batch, h, w, c;

            h     = parameters.H;
            w     = parameters.W;
            c     = parameters.C;
            batch = parameters.Batch;
            if (!(h != 0 && w != 0 && c != 0))
            {
                Utils.Error("Layer before convolutional Layer must output image.");
            }
            bool batchNormalize = OptionList.option_find_int_quiet(options, "batch_normalize", 0) != 0;
            bool binary         = OptionList.option_find_int_quiet(options, "binary", 0) != 0;
            bool xnor           = OptionList.option_find_int_quiet(options, "xnor", 0) != 0;

            Layer layer = Layer.make_convolutional_layer(batch, h, w, c, n, size, stride, padding, activation, batchNormalize, binary, xnor, parameters.Net.Adam);

            layer.Flipped = OptionList.option_find_int_quiet(options, "flipped", 0);
            layer.Dot     = OptionList.option_find_float_quiet(options, "dot", 0);
            if (parameters.Net.Adam)
            {
                layer.B1  = parameters.Net.B1;
                layer.B2  = parameters.Net.B2;
                layer.Eps = parameters.Net.Eps;
            }

            return(layer);
        }
Пример #5
0
        private static Layer parse_shortcut(KeyValuePair[] options, SizeParams parameters, Network net)
        {
            string l     = OptionList.option_find(options, "from");
            int    index = int.Parse(l);

            if (index < 0)
            {
                index = parameters.Index + index;
            }

            int   batch = parameters.Batch;
            Layer from  = net.Layers[index];

            Layer s = Layer.make_shortcut_layer(batch, index, parameters.W, parameters.H, parameters.C, from.OutW, from.OutH, from.OutC);

            string     activationS = OptionList.option_find_str(options, "activation", "linear");
            Activation activation  = ActivationsHelper.Get_activation(activationS);

            s.Activation = activation;
            return(s);
        }
Пример #6
0
        private static Layer parse_local(KeyValuePair[] options, SizeParams parameters)
        {
            int        n           = OptionList.option_find_int(options, "filters", 1);
            int        size        = OptionList.option_find_int(options, "size", 1);
            int        stride      = OptionList.option_find_int(options, "stride", 1);
            int        pad         = OptionList.option_find_int(options, "pad", 0);
            string     activationS = OptionList.option_find_str(options, "activation", "logistic");
            Activation activation  = ActivationsHelper.Get_activation(activationS);

            int batch, h, w, c;

            h     = parameters.H;
            w     = parameters.W;
            c     = parameters.C;
            batch = parameters.Batch;
            if (!(h != 0 && w != 0 && c != 0))
            {
                Utils.Error("Layer before local Layer must output image.");
            }

            Layer layer = new Layer(batch, h, w, c, n, size, stride, pad, activation);

            return(layer);
        }