MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DataNoiseParameter.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace MyCaffe.param
10{
14 [Serializable]
15 [TypeConverter(typeof(ExpandableObjectConverter))]
16 public class DataNoiseParameter
17 {
18 int m_nNoiseDataLabel = -1;
19 bool m_bUseNoisyMean = true;
20 string m_strNoisyDataSavePath = null;
21 FillerParameter m_noiseFiller = new FillerParameter("constant", 1);
22
27 {
28 }
29
33 [Description("Specifies to multipy the noisy data by the mean to produce the final noisy data (default = true). NOTE: When using this setting, the filler should be configured to produce values in the range [0,1].")]
34 public bool use_noisy_mean
35 {
36 get { return m_bUseNoisyMean; }
37 set { m_bUseNoisyMean = value; }
38 }
39
43 [Description("Specifies the label used with each noise filled data used when 'use_noise_for_match' = True (default = -1).")]
45 {
46 get { return m_nNoiseDataLabel; }
47 set { m_nNoiseDataLabel = value; }
48 }
49
53 [Description("Specifies the noise filler used when 'use_noise_for_nonmatch' = True. By default the 'noise_filler' is set to CONSTANT(1) which, when used with the 'use_noisy_mean' = True, uses the mean image as the data noise.")]
55 {
56 get { return m_noiseFiller; }
57 set { m_noiseFiller = value; }
58 }
59
63 [Description("Optionally, specifies the path where the noisy data image is saved for debugging (default = null, which ignores this setting).")]
64 public string noisy_save_path
65 {
66 get { return m_strNoisyDataSavePath; }
67 set { m_strNoisyDataSavePath = value; }
68 }
69
70 private string noisy_save_path_persist
71 {
72 get
73 {
74 string strPath = Utility.Replace(m_strNoisyDataSavePath, ':', ';');
75 return Utility.Replace(strPath, ' ', '~');
76 }
77
78 set
79 {
80 string strPath = Utility.Replace(value, ';', ':');
81 m_strNoisyDataSavePath = Utility.Replace(strPath, '~', ' ');
82 }
83 }
84
89 public void Copy(DataNoiseParameter pSrc)
90 {
91 if (pSrc == null)
92 return;
93
94 m_bUseNoisyMean = pSrc.m_bUseNoisyMean;
95 m_nNoiseDataLabel = pSrc.m_nNoiseDataLabel;
96 m_strNoisyDataSavePath = pSrc.m_strNoisyDataSavePath;
97
98 if (pSrc.m_noiseFiller != null)
99 m_noiseFiller = pSrc.m_noiseFiller.Clone();
100 }
101
107 public RawProto ToProto(string strName)
108 {
109 RawProtoCollection rgChildren = new RawProtoCollection();
110
111 rgChildren.Add("use_noisy_mean", m_bUseNoisyMean.ToString());
112 rgChildren.Add("noise_data_label", m_nNoiseDataLabel.ToString());
113 rgChildren.Add("noisy_data_path", noisy_save_path_persist);
114
115 if (noise_filler != null)
116 rgChildren.Add(noise_filler.ToProto("noise_filler"));
117
118 return new RawProto(strName, "", rgChildren);
119 }
120
121
129 {
130 string strVal;
131
132 if (p == null)
133 p = new DataNoiseParameter();
134
135 if ((strVal = rp.FindValue("use_noisy_mean")) != null)
136 p.use_noisy_mean = bool.Parse(strVal);
137
138 if ((strVal = rp.FindValue("noise_data_label")) != null)
139 p.noise_data_label = int.Parse(strVal);
140
141 if ((strVal = rp.FindValue("noisy_data_path")) != null)
142 p.noisy_save_path_persist = strVal;
143
144 RawProto rpNoiseFiller = rp.FindChild("noise_filler");
145 if (rpNoiseFiller != null)
146 p.noise_filler = FillerParameter.FromProto(rpNoiseFiller);
147
148 return p;
149 }
150 }
151}
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The Utility class provides general utility funtions.
Definition: Utility.cs:35
static string Replace(string str, char ch1, char ch2)
Replaces each instance of one character with another character in a given string.
Definition: Utility.cs:864
The DataNoiseParameter is used by the DataParameter when the 'enable_noise_for_nonmatch' = True,...
string noisy_save_path
(/b optional, default = null) Specifies the path where the noisy data image is saved,...
RawProto ToProto(string strName)
Convert the DataNoiseParameter into a RawProto.
static DataNoiseParameter FromProto(RawProto rp, DataNoiseParameter p=null)
Parses the parameter from a RawProto.
bool use_noisy_mean
(optional, default = true) When true the noise is applied to the mean and used as the noisy data....
int noise_data_label
(optional, default = -1) Specifies the label used with each noise filled data used when 'use_noise_fo...
FillerParameter noise_filler
Specifies the noise filler used when 'use_noise_for_nonmatch' = true. By default the 'noise_filter' i...
void Copy(DataNoiseParameter pSrc)
Copies the specified source data noise parameter to this one.
Specifies the filler parameters used to create each Filler.
static FillerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
FillerParameter Clone()
Creates a new copy of this instance of the parameter.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12