/** @copydoc LayerParameterBase::Clone */ public override LayerParameterBase Clone() { EngineParameter p = new EngineParameter(); p.Copy(this); 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 SPPParameter FromProto(RawProto rp) { string strVal; SPPParameter p = new SPPParameter(); p.Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("method")) != null) { switch (strVal) { case "MAX": p.pool = PoolingParameter.PoolingMethod.MAX; break; case "AVE": p.pool = PoolingParameter.PoolingMethod.AVE; break; case "STOCHASTIC": p.pool = PoolingParameter.PoolingMethod.STOCHASTIC; break; default: throw new Exception("Unknown pooling 'method' value: " + strVal); } } if ((strVal = rp.FindValue("pyramid_height")) != null) { p.pyramid_height = uint.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 EngineParameter FromProto(RawProto rp) { string strVal; EngineParameter p = new EngineParameter(); if ((strVal = rp.FindValue("engine")) != null) { switch (strVal) { case "DEFAULT": p.engine = Engine.DEFAULT; break; case "CAFFE": p.engine = Engine.CAFFE; break; case "CUDNN": p.engine = Engine.CUDNN; break; default: throw new Exception("Unknown 'engine' value: " + 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 TanhParameter FromProto(RawProto rp) { TanhParameter p = new TanhParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); 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 SigmoidParameter FromProto(RawProto rp) { SigmoidParameter p = new SigmoidParameter(); p.Copy(EngineParameter.FromProto(rp)); 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 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 LayerParameterBase::Load */ public override object Load(System.IO.BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); EngineParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } return(p); }
/** @copydoc EngineParameter::FromProto */ public static new ReLUParameter FromProto(RawProto rp) { string strVal; ReLUParameter p = new ReLUParameter(); p.Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("negative_slope")) != null) p.negative_slope = 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 new SoftmaxParameter FromProto(RawProto rp) { string strVal; SoftmaxParameter p = new SoftmaxParameter(); p.Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("axis")) != null) { p.axis = int.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 EluParameter FromProto(RawProto rp) { string strVal; EluParameter p = new EluParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("alpha")) != null) { p.alpha = ParseDouble(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 SwishParameter FromProto(RawProto rp) { string strVal; SwishParameter p = new SwishParameter(); p.Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("beta")) != null) { p.beta = 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 new LRNParameter FromProto(RawProto rp) { string strVal; LRNParameter p = new LRNParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("local_size")) != null) { p.local_size = uint.Parse(strVal); } if ((strVal = rp.FindValue("alpha")) != null) { p.alpha = ParseDouble(strVal); } if ((strVal = rp.FindValue("beta")) != null) { p.beta = ParseDouble(strVal); } if ((strVal = rp.FindValue("norm_region")) != null) { switch (strVal) { case "ACROSS_CHANNELS": p.norm_region = NormRegion.ACROSS_CHANNELS; break; case "WITHIN_CHANNEL": p.norm_region = NormRegion.WITHIN_CHANNEL; break; default: throw new Exception("Unknown 'norm_region' value: " + strVal); } } if ((strVal = rp.FindValue("k")) != null) { p.k = ParseDouble(strVal); } return(p); }
/// <summary> /// Parse a RawProto into a new instance of the parameter. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new KernelParameter FromProto(RawProto rp) { KernelParameter p = new KernelParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); p.m_rgPad = rp.FindArray <uint>("pad"); p.m_rgStride = rp.FindArray <uint>("stride"); p.m_rgKernelSize = rp.FindArray <uint>("kernel_size"); p.m_rgDilation = rp.FindArray <uint>("dilation"); p.m_nPadH = (uint?)rp.FindValue("pad_h", typeof(uint)); p.m_nPadW = (uint?)rp.FindValue("pad_w", typeof(uint)); p.m_nStrideH = (uint?)rp.FindValue("stride_h", typeof(uint)); p.m_nStrideW = (uint?)rp.FindValue("stride_w", typeof(uint)); p.m_nKernelH = (uint?)rp.FindValue("kernel_h", typeof(uint)); p.m_nKernelW = (uint?)rp.FindValue("kernel_w", typeof(uint)); return(p); }
/** @copydoc EngineParameter::FromProto */ public static new DropoutParameter FromProto(RawProto rp) { string strVal; DropoutParameter p = new DropoutParameter(); ((EngineParameter)p).Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("dropout_ratio")) != null) { p.dropout_ratio = double.Parse(strVal); } if ((strVal = rp.FindValue("seed")) != null) { p.seed = long.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 ClipParameter FromProto(RawProto rp) { string strVal; ClipParameter p = new ClipParameter(); p.Copy(EngineParameter.FromProto(rp)); if ((strVal = rp.FindValue("min")) != null) { p.min = double.Parse(strVal); } if ((strVal = rp.FindValue("max")) != null) { p.max = 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 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); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { EngineParameter p = (EngineParameter)src; m_engine = p.m_engine; }