/** @copydoc KernelParameter::Copy */ public override void Copy(LayerParameterBase src) { base.Copy(src); if (src is ConvolutionParameter) { ConvolutionParameter p = (ConvolutionParameter)src; m_nNumOutput = p.m_nNumOutput; m_bBiasTerm = p.m_bBiasTerm; m_nGroup = p.m_nGroup; if (p.m_fillerParam_bias != null) { m_fillerParam_bias = p.m_fillerParam_bias.Clone(); } if (p.m_fillerParam_weights != null) { m_fillerParam_weights = p.m_fillerParam_weights.Clone(); } m_nAxis = p.m_nAxis; m_bForceNDIm2Col = p.m_bForceNDIm2Col; m_nCudnnWorkspaceLimit = p.m_nCudnnWorkspaceLimit; m_bCudnnWorkspaceAllowOnGroups = p.m_bCudnnWorkspaceAllowOnGroups; } }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { base.Copy(src); if (src is BatchNormParameter) { BatchNormParameter p = (BatchNormParameter)src; m_bUseGlobalStats = p.m_bUseGlobalStats; m_dfEps = p.m_dfEps; m_dfMovingAverageFraction = p.m_dfMovingAverageFraction; m_bScaleBias = p.m_bScaleBias; m_biasFiller = p.m_biasFiller; if (p.m_scaleFiller != null) { m_scaleFiller = p.m_scaleFiller.Clone(); } else { m_scaleFiller = null; } if (p.m_biasFiller != null) { m_biasFiller = p.m_biasFiller.Clone(); } else { m_biasFiller = null; } } }
/// <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); }
/// <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); }
/// <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); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { RecurrentParameter p = (RecurrentParameter)src; m_nNumOutput = p.num_output; m_weight_filler = p.weight_filler.Clone(); m_bias_filler = p.bias_filler.Clone(); m_bDebugInfo = p.debug_info; m_bExposeHidden = p.expose_hidden; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { LSTMSimpleParameter p = (LSTMSimpleParameter)src; m_nNumOutput = p.m_nNumOutput; m_dfClippingThreshold = p.m_dfClippingThreshold; m_fillerWeights = p.m_fillerWeights.Clone(); m_fillerBias = p.m_fillerBias.Clone(); m_nBatchSize = p.m_nBatchSize; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { PReLUParameter p = (PReLUParameter)src; if (p.m_filler != null) { m_filler = p.m_filler.Clone(); } m_bChannelShared = p.m_bChannelShared; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { LSTMAttentionParameter p = (LSTMAttentionParameter)src; m_nNumOutput = p.m_nNumOutput; m_nNumIpOutput = p.m_nNumIpOutput; m_dfClippingThreshold = p.m_dfClippingThreshold; m_fillerWeights = p.m_fillerWeights.Clone(); m_fillerBias = p.m_fillerBias.Clone(); m_bEnableClockworkForgetGateBias = p.m_bEnableClockworkForgetGateBias; m_bEnableAttention = p.m_bEnableAttention; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { ScaleParameter p = (ScaleParameter)src; base.Copy(src); m_bBiasTerm = p.m_bBiasTerm; if (p.m_FillerBias != null) { m_FillerBias = p.m_FillerBias.Clone(); } }
/// <summary> /// Creates a new copy of this instance of the parameter. /// </summary> /// <returns>A new instance of this parameter is returned.</returns> public FillerParameter Clone() { FillerParameter p = new FillerParameter(); p.m_strType = m_strType; p.m_fVal = m_fVal; p.m_fMin = m_fMin; p.m_fMax = m_fMax; p.m_fMean = m_fMean; p.m_fStd = m_fStd; p.m_nSparse = m_nSparse; p.m_varianceNorm = m_varianceNorm; return(p); }
/// <summary> /// Copies the specified source data noise parameter to this one. /// </summary> /// <param name="pSrc">Specifies the source data noise parameter.</param> public void Copy(DataNoiseParameter pSrc) { if (pSrc == null) { return; } m_bUseNoisyMean = pSrc.m_bUseNoisyMean; m_nNoiseDataLabel = pSrc.m_nNoiseDataLabel; m_strNoisyDataSavePath = pSrc.m_strNoisyDataSavePath; if (pSrc.m_noiseFiller != null) { m_noiseFiller = pSrc.m_noiseFiller.Clone(); } }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { BiasParameter p = (BiasParameter)src; m_nAxis = p.m_nAxis; m_nNumAxes = p.m_nNumAxes; if (p.m_filler != null) { m_filler = p.m_filler.Clone(); } else { m_filler = null; } }
/// <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); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { base.Copy(src); if (src is RecurrentParameter) { RecurrentParameter p = (RecurrentParameter)src; m_nNumOutput = p.num_output; m_weight_filler = p.weight_filler.Clone(); m_bias_filler = p.bias_filler.Clone(); m_bDebugInfo = p.debug_info; m_bExposeHidden = p.expose_hidden; m_dfDropoutRatio = p.dropout_ratio; m_lDropoutSeed = p.dropout_seed; m_nNumLayers = p.num_layers; } }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { AttentionParameter p = (AttentionParameter)src; m_nDim = p.dim; m_nAxis = p.m_nAxis; if (p.m_fillerParam_bias != null) { m_fillerParam_bias = p.m_fillerParam_bias.Clone(); } if (p.m_fillerParam_weights != null) { m_fillerParam_weights = p.m_fillerParam_weights.Clone(); } }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { EmbedParameter p = (EmbedParameter)src; m_nNumOutput = p.m_nNumOutput; m_nInputDim = p.m_nInputDim; m_bBiasTerm = p.m_bBiasTerm; if (p.m_fillerParam_bias != null) { m_fillerParam_bias = p.m_fillerParam_bias.Clone(); } if (p.m_fillerParam_weights != null) { m_fillerParam_weights = p.m_fillerParam_weights.Clone(); } }
/// <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 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); }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { InnerProductParameter p = (InnerProductParameter)src; m_nNumOutput = p.m_nNumOutput; m_bBiasTerm = p.m_bBiasTerm; if (p.m_fillerParam_bias != null) { m_fillerParam_bias = p.m_fillerParam_bias.Clone(); } if (p.m_fillerParam_weights != null) { m_fillerParam_weights = p.m_fillerParam_weights.Clone(); } m_nAxis = p.m_nAxis; m_bTranspose = p.m_bTranspose; }
/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { base.Copy(src); if (src is RecurrentParameter) { RecurrentParameter p = (RecurrentParameter)src; m_nNumOutput = p.num_output; m_weight_filler = p.weight_filler.Clone(); m_bias_filler = p.bias_filler.Clone(); m_bDebugInfo = p.debug_info; m_bExposeHiddenInput = p.expose_hidden_input; m_bExposeHiddenOutput = p.expose_hidden_output; m_dfDropoutRatio = p.dropout_ratio; m_lDropoutSeed = p.dropout_seed; m_nNumLayers = p.num_layers; m_bBidirectional = p.bidirectional; m_bCudnnEnableTensorCores = p.m_bCudnnEnableTensorCores; } }
/// <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); }
/// <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); }
/// <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); }
/// <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 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); }
/// <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 FillerParameter FromProto(RawProto rp) { string strVal; if ((strVal = rp.FindValue("type")) == null) { throw new Exception("Could not find 'type'"); } FillerParameter p = new FillerParameter(strVal); if ((strVal = rp.FindValue("value")) != null) { p.value = double.Parse(strVal); } if ((strVal = rp.FindValue("min")) != null) { p.min = double.Parse(strVal); } if ((strVal = rp.FindValue("max")) != null) { p.max = double.Parse(strVal); } if ((strVal = rp.FindValue("mean")) != null) { p.mean = double.Parse(strVal); } if ((strVal = rp.FindValue("std")) != null) { p.std = double.Parse(strVal); } if ((strVal = rp.FindValue("sparse")) != null) { p.sparse = int.Parse(strVal); } if ((strVal = rp.FindValue("variance_norm")) != null) { switch (strVal) { case "FAN_IN": p.variance_norm = VarianceNorm.FAN_IN; break; case "FAN_OUT": p.variance_norm = VarianceNorm.FAN_OUT; break; case "AVERAGE": p.variance_norm = VarianceNorm.AVERAGE; break; default: throw new Exception("Unknown 'variance_norm' value: " + strVal); } } return(p); }