Beispiel #1
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <param name="p">Optionally, specifies an instance to load.  If <i>null</i>, a new instance is created and loaded.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static DataNoiseParameter FromProto(RawProto rp, DataNoiseParameter p = null)
        {
            string strVal;

            if (p == null)
            {
                p = new DataNoiseParameter();
            }

            if ((strVal = rp.FindValue("use_noisy_mean")) != null)
            {
                p.use_noisy_mean = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("noise_data_label")) != null)
            {
                p.noise_data_label = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("noisy_data_path")) != null)
            {
                p.noisy_save_path_persist = strVal;
            }

            RawProto rpNoiseFiller = rp.FindChild("noise_filler");

            if (rpNoiseFiller != null)
            {
                p.noise_filler = FillerParameter.FromProto(rpNoiseFiller);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static AttentionParameter FromProto(RawProto rp)
        {
            string             strVal;
            AttentionParameter p = new AttentionParameter();

            if ((strVal = rp.FindValue("axis")) != null)
            {
                p.axis = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("dim")) != null)
            {
                p.dim = uint.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            return(p);
        }
Beispiel #3
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static new RecurrentParameter FromProto(RawProto rp)
        {
            string             strVal;
            RecurrentParameter p = new RecurrentParameter();

            ((EngineParameter)p).Copy(EngineParameter.FromProto(rp));

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            if ((strVal = rp.FindValue("debug_info")) != null)
            {
                p.debug_info = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("expose_hidden")) != null)
            {
                p.expose_hidden = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("dropout_ratio")) != null)
            {
                p.dropout_ratio = ParseDouble(strVal);
            }

            if ((strVal = rp.FindValue("dropout_seed")) != null)
            {
                p.dropout_seed = long.Parse(strVal);
            }

            if ((strVal = rp.FindValue("num_layers")) != null)
            {
                p.num_layers = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("cudnn_enable_tensor_cores")) != null)
            {
                p.cudnn_enable_tensor_cores = bool.Parse(strVal);
            }

            return(p);
        }
        /** @copydoc KernelParameter::FromProto */
        public static new ConvolutionParameter FromProto(RawProto rp)
        {
            string strVal;
            ConvolutionParameter p = new ConvolutionParameter();

            ((KernelParameter)p).Copy(KernelParameter.FromProto(rp));

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("bias_term")) != null)
            {
                p.bias_term = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("group")) != null)
            {
                p.group = uint.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            if ((strVal = rp.FindValue("axis")) != null)
            {
                p.axis = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_nd_im2col")) != null)
            {
                p.force_nd_im2col = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("cudnn_workspace_limit")) != null)
            {
                p.cudnn_workspace_limit = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("cudnn_worspace_allow_on_groups")) != null)
            {
                p.cudnn_workspace_allow_on_groups = bool.Parse(strVal);
            }

            return(p);
        }
Beispiel #5
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static InnerProductParameter FromProto(RawProto rp)
        {
            string strVal;
            InnerProductParameter p = new InnerProductParameter();

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("bias_term")) != null)
            {
                p.bias_term = bool.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            if ((strVal = rp.FindValue("axis")) != null)
            {
                p.axis = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("transpose")) != null)
            {
                p.transpose = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("min_top_axes")) != null)
            {
                p.min_top_axes = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("enable_noise")) != null)
            {
                p.enable_noise = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("sigma_init")) != null)
            {
                p.sigma_init = double.Parse(strVal);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static LSTMAttentionParameter FromProto(RawProto rp)
        {
            string strVal;
            LSTMAttentionParameter p = new LSTMAttentionParameter();

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("num_output_ip")) != null)
            {
                p.num_output_ip = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("clipping_threshold")) != null)
            {
                p.clipping_threshold = ParseDouble(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            if ((strVal = rp.FindValue("enable_clockwork_forgetgate_bias")) != null)
            {
                p.enable_clockwork_forgetgate_bias = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("enable_attention")) != null)
            {
                p.enable_attention = bool.Parse(strVal);
            }

            return(p);
        }
Beispiel #7
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static PReLUParameter FromProto(RawProto rp)
        {
            string         strVal;
            PReLUParameter p = new PReLUParameter();

            RawProto rpFiller = rp.FindChild("filler");

            if (rpFiller != null)
            {
                p.m_filler = FillerParameter.FromProto(rpFiller);
            }

            if ((strVal = rp.FindValue("channel_shared")) != null)
            {
                p.channel_shared = bool.Parse(strVal);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static new ScaleParameter FromProto(RawProto rp)
        {
            string         strVal;
            ScaleParameter p = new ScaleParameter();

            if ((strVal = rp.FindValue("bias_term")) != null)
            {
                p.bias_term = bool.Parse(strVal);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static new BatchNormParameter FromProto(RawProto rp)
        {
            string             strVal;
            BatchNormParameter p = new BatchNormParameter();

            ((EngineParameter)p).Copy(EngineParameter.FromProto(rp));

            if ((strVal = rp.FindValue("use_global_stats")) != null)
            {
                p.use_global_stats = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("moving_average_fraction")) != null)
            {
                p.moving_average_fraction = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("eps")) != null)
            {
                p.eps = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("scale_bias")) != null)
            {
                p.scale_bias = bool.Parse(strVal);

                RawProto rp1;

                if ((rp1 = rp.FindChild("scale_filler")) != null)
                {
                    p.scale_filler = FillerParameter.FromProto(rp1);
                }

                if ((rp1 = rp.FindChild("bias_filler")) != null)
                {
                    p.bias_filler = FillerParameter.FromProto(rp1);
                }
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static BiasParameter FromProto(RawProto rp)
        {
            string        strVal;
            BiasParameter p = new BiasParameter();

            if ((strVal = rp.FindValue("axis")) != null)
            {
                p.axis = int.Parse(strVal);
            }

            if ((strVal = rp.FindValue("num_axes")) != null)
            {
                p.num_axes = int.Parse(strVal);
            }

            if ((rp = rp.FindChild("filler")) != null)
            {
                p.m_filler = FillerParameter.FromProto(rp);
            }

            return(p);
        }
Beispiel #11
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static RecurrentParameter FromProto(RawProto rp)
        {
            string             strVal;
            RecurrentParameter p = new RecurrentParameter();

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            if ((strVal = rp.FindValue("debug_info")) != null)
            {
                p.debug_info = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("expose_hidden")) != null)
            {
                p.expose_hidden = bool.Parse(strVal);
            }

            return(p);
        }
Beispiel #12
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static DummyDataParameter FromProto(RawProto rp)
        {
            DummyDataParameter p = new DummyDataParameter();
            RawProtoCollection rgp;

            rgp = rp.FindChildren("data_filler");
            foreach (RawProto child in rgp)
            {
                p.data_filler.Add(FillerParameter.FromProto(child));
            }

            rgp = rp.FindChildren("shape");
            foreach (RawProto child in rgp)
            {
                p.shape.Add(BlobShape.FromProto(child));
            }

            p.num      = rp.FindArray <uint>("num");
            p.channels = rp.FindArray <uint>("channels");
            p.height   = rp.FindArray <uint>("height");
            p.width    = rp.FindArray <uint>("width");

            string strVal;

            if ((strVal = rp.FindValue("primary_data")) != null)
            {
                p.primary_data = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_refill")) != null)
            {
                p.force_refill = bool.Parse(strVal);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static EmbedParameter FromProto(RawProto rp)
        {
            string         strVal;
            EmbedParameter p = new EmbedParameter();

            if ((strVal = rp.FindValue("num_output")) != null)
            {
                p.num_output = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("input_dim")) != null)
            {
                p.input_dim = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("bias_term")) != null)
            {
                p.bias_term = bool.Parse(strVal);
            }

            RawProto rpWeightFiller = rp.FindChild("weight_filler");

            if (rpWeightFiller != null)
            {
                p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
            }

            RawProto rpBiasFiller = rp.FindChild("bias_filler");

            if (rpBiasFiller != null)
            {
                p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
            }

            return(p);
        }
Beispiel #14
0
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static DummyDataParameter FromProto(RawProto rp)
        {
            DummyDataParameter p = new DummyDataParameter();
            RawProtoCollection rgp;

            rgp = rp.FindChildren("data_filler");
            foreach (RawProto child in rgp)
            {
                p.data_filler.Add(FillerParameter.FromProto(child));
            }

            rgp = rp.FindChildren("shape");
            foreach (RawProto child in rgp)
            {
                p.shape.Add(BlobShape.FromProto(child));
            }

            p.num      = rp.FindArray <uint>("num");
            p.channels = rp.FindArray <uint>("channels");
            p.height   = rp.FindArray <uint>("height");
            p.width    = rp.FindArray <uint>("width");

            return(p);
        }