/** @copydoc LayerParameterBase::Copy */ public override void Copy(LayerParameterBase src) { MultiBoxLossParameter p = src as MultiBoxLossParameter; m_locLossType = p.loc_loss_type; m_confLossType = p.conf_loss_type; m_fLocWeight = p.loc_weight; m_nNumClasses = p.num_classes; m_bShareLocation = p.share_location; m_matchType = p.match_type; m_fOverlapThreshold = p.overlap_threshold; m_nBackgroundLabelId = p.background_label_id; m_bUseDifficultGt = p.use_difficult_gt; m_bDoNegMining = p.do_neg_mining; m_fNegPosRatio = p.neg_pos_ratio; m_fNegOverlap = p.neg_overlap; m_codeType = p.code_type; m_bEncodeVarianceInTarget = p.encode_variance_in_target; m_bMapObjectToAgnostic = p.map_object_to_agnostic; m_bIgnoreCrossBoundaryBbox = p.ignore_cross_boundary_bbox; m_bBpInside = p.bp_inside; m_miningType = p.mining_type; m_nmsParam = p.nms_param.Clone(); m_nSampleSize = p.sample_size; m_bUsePriorForNms = p.use_prior_for_nms; m_bUsePriorForMatching = p.use_prior_for_matching; }
/** @copydoc LayerParameterBase::Load */ public override object Load(BinaryReader br, bool bNewInstance = true) { RawProto proto = RawProto.Parse(br.ReadString()); MultiBoxLossParameter p = FromProto(proto); if (!bNewInstance) { Copy(p); } 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 MultiBoxLossParameter FromProto(RawProto rp) { MultiBoxLossParameter p = new MultiBoxLossParameter(); string strVal; if ((strVal = rp.FindValue("loc_loss_type")) != null) { p.loc_loss_type = LocLossTypeFromString(strVal); } if ((strVal = rp.FindValue("conf_loss_type")) != null) { p.conf_loss_type = ConfLossTypeFromString(strVal); } if ((strVal = rp.FindValue("loc_weight")) != null) { p.loc_weight = float.Parse(strVal); } if ((strVal = rp.FindValue("num_classes")) != null) { p.num_classes = uint.Parse(strVal); } if ((strVal = rp.FindValue("share_location")) != null) { p.share_location = bool.Parse(strVal); } if ((strVal = rp.FindValue("match_type")) != null) { p.match_type = MatchTypeFromString(strVal); } if ((strVal = rp.FindValue("overlap_threshold")) != null) { p.overlap_threshold = float.Parse(strVal); } if ((strVal = rp.FindValue("background_label_id")) != null) { p.background_label_id = uint.Parse(strVal); } if ((strVal = rp.FindValue("use_difficult_gt")) != null) { p.use_difficult_gt = bool.Parse(strVal); } if ((strVal = rp.FindValue("do_neg_mining")) != null) { p.do_neg_mining = bool.Parse(strVal); } if ((strVal = rp.FindValue("neg_pos_ratio")) != null) { p.neg_pos_ratio = float.Parse(strVal); } if ((strVal = rp.FindValue("neg_overlap")) != null) { p.neg_overlap = float.Parse(strVal); } if ((strVal = rp.FindValue("code_type")) != null) { p.code_type = PriorBoxParameter.CodeTypeFromString(strVal); } if ((strVal = rp.FindValue("encode_variance_in_target")) != null) { p.encode_variance_in_target = bool.Parse(strVal); } if ((strVal = rp.FindValue("map_object_to_agnostic")) != null) { p.map_object_to_agnostic = bool.Parse(strVal); } if ((strVal = rp.FindValue("ignore_corss_boundary_bbox")) != null) { p.ignore_cross_boundary_bbox = bool.Parse(strVal); } if ((strVal = rp.FindValue("bp_inside")) != null) { p.bp_inside = bool.Parse(strVal); } if ((strVal = rp.FindValue("mining_type")) != null) { p.mining_type = MiningTypeFromString(strVal); } RawProto rpNms = rp.FindChild("nms_param"); if (rpNms != null) { p.nms_param = NonMaximumSuppressionParameter.FromProto(rpNms); } if ((strVal = rp.FindValue("sample_size")) != null) { p.sample_size = int.Parse(strVal); } if ((strVal = rp.FindValue("use_prior_for_nms")) != null) { p.use_prior_for_nms = bool.Parse(strVal); } return(p); }