MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
StateBase.cs
1using MyCaffe.basecode;
2using MyCaffe.gym;
3using System;
4using System.Collections.Generic;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9
10namespace MyCaffe.trainers
11{
15 public class StateBase
16 {
17 bool m_bDone = false;
18 bool m_bValid = true;
19 double m_dfReward = 0;
20 int m_nActionCount = 0;
21 SimpleDatum m_data = null;
22 SimpleDatum m_clip = null;
23 SimpleDatum m_label = null;
24 double[] m_rgState = null;
25 double[] m_rgClip = null;
26 Image m_img = null;
27 double m_dfTestingPercent = 0.2; // default to 20% of the tail end of the data for testing.
28 List<DataPoint> m_rgHistory = null;
29
33 public StateBase(int nActionCount)
34 {
35 m_nActionCount = nActionCount;
36 }
37
44 public double TestingPercent
45 {
46 get { return m_dfTestingPercent; }
47 set { m_dfTestingPercent = value; }
48 }
49
53 public bool IsValid
54 {
55 get { return m_bValid; }
56 set { m_bValid = value; }
57 }
58
62 public double Reward
63 {
64 get { return m_dfReward; }
65 set { m_dfReward = value; }
66 }
67
71 public bool Done
72 {
73 get { return m_bDone; }
74 set { m_bDone = value; }
75 }
76
80 public List<DataPoint> History
81 {
82 get { return m_rgHistory; }
83 set { m_rgHistory = value; }
84 }
85
89 public int ActionCount
90 {
91 get { return m_nActionCount; }
92 }
93
98 {
99 get { return m_data; }
100 set { m_data = value; }
101 }
102
106 public double[] RawState
107 {
108 get { return m_rgState; }
109 set { m_rgState = value; }
110 }
111
116 {
117 get { return m_clip; }
118 set { m_clip = value; }
119 }
120
124 public double[] RawClip
125 {
126 get { return m_rgClip; }
127 set { m_rgClip = value; }
128 }
129
134 {
135 get { return m_label; }
136 set { m_label = value; }
137 }
138
142 public Image RawImage
143 {
144 get { return m_img; }
145 set { m_img = value; }
146 }
147
152 public virtual StateBase Clone()
153 {
154 StateBase s = new StateBase(m_nActionCount);
155
156 s.m_bDone = m_bDone;
157 s.m_bValid = m_bValid;
158 s.m_dfReward = m_dfReward;
159 s.m_data = new SimpleDatum(m_data, true);
160 s.m_rgState = Utility.Clone<double>(m_rgState);
161
162 if (m_clip != null)
163 s.m_clip = new SimpleDatum(m_clip, true);
164
165 s.m_img = (m_img == null) ? null : new Bitmap(m_img);
166
167 return s;
168 }
169
174 public override string ToString()
175 {
176 double[] rgData = m_data.GetData<double>();
177
178 string str = "{";
179 for (int i = 0; i < rgData.Length && i < 5; i++)
180 {
181 str += rgData[i].ToString("N4") + ",";
182 }
183 str = str.TrimEnd(',');
184 str += "}";
185
186 return "State = " + str + " Done = " + m_bDone.ToString();
187 }
188 }
189}
The SimpleDatum class holds a data input within host memory.
Definition: SimpleDatum.cs:161
override string ToString()
Return a string representation of the SimpleDatum.
The Utility class provides general utility funtions.
Definition: Utility.cs:35
The StateBase is the base class for the state of each observation - this is defined by actual trainer...
Definition: StateBase.cs:16
bool IsValid
Get/set whether or not the state is valid.
Definition: StateBase.cs:54
bool Done
Get/set whether the state is done or not.
Definition: StateBase.cs:72
StateBase(int nActionCount)
The constructor.
Definition: StateBase.cs:33
virtual StateBase Clone()
Copy the state base information.
Definition: StateBase.cs:152
override string ToString()
Return the string representation of the state.
Definition: StateBase.cs:174
double Reward
Get/set the reward of the state.
Definition: StateBase.cs:63
double[] RawState
Get/set the raw state data.
Definition: StateBase.cs:107
SimpleDatum Label
Get/set the label data associated with the state. This field is optional.
Definition: StateBase.cs:134
double TestingPercent
Get/set the percentage of the data to reserve for testing.
Definition: StateBase.cs:45
List< DataPoint > History
Get/set the data history (if any exists).
Definition: StateBase.cs:81
SimpleDatum Data
Returns other data associated with the state.
Definition: StateBase.cs:98
double[] RawClip
Get/set the raw clip data.
Definition: StateBase.cs:125
Image RawImage
Get/set the image (if any exists)
Definition: StateBase.cs:143
int ActionCount
Returns the number of actions.
Definition: StateBase.cs:90
SimpleDatum Clip
Returns the clip data assoicated with the state.
Definition: StateBase.cs:116
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
The MyCaffe.trainers namespace contains all reinforcement and recurrent learning trainers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12