5using System.Collections.Generic;
8using System.Drawing.Drawing2D;
9using System.Drawing.Imaging;
12using System.Runtime.InteropServices;
15using System.Threading.Tasks;
24 string m_strName =
"DataGeneral";
27 Dictionary<string, int> m_rgActions =
new Dictionary<string, int>();
75 if (properties !=
null)
110 get {
return m_strName; }
154 public Tuple<Bitmap, SimpleDatum>
Render(
bool bShowUi,
int nWidth,
int nHeight,
bool bGetAction)
156 List<double> rgData =
new List<double>();
157 return Render(bShowUi, nWidth, nHeight, rgData.ToArray(), bGetAction);
169 public Tuple<Bitmap, SimpleDatum>
Render(
bool bShowUi,
int nWidth,
int nHeight,
double[] rgData,
bool bGetAction)
183 return Step(-1, bGetLabel);
193 public Tuple<State, double, bool>
Step(
int nAction,
bool bGetLabel,
PropertySet propExtra =
null)
195 DataState data =
new DataState();
200 return new Tuple<State, double, bool>(data, 0, (sd ==
null) ?
true :
false);
220 log.
WriteLine(
"WARNING: This gym only supports the BLOB type, the datatype will be changed to BLOB.");
222 throw new Exception(
"This gym only supports the BLOB type.");
259 get {
return m_phase; }
260 set { m_phase = value; }
264 class DataState : State
272 public DataState(DataState s)
277 public override State Clone()
279 DataState data =
new DataState(
this);
289 public override SimpleDatum GetData(
bool bNormalize, out
int nDataLen)
291 nDataLen = (m_sd ==
null) ? 0 : m_sd.
ItemCount;
The CryptoRandom is a random number generator that can use either the standard .Net Random objec or t...
The Log class provides general output in text form.
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
Specifies a key-value pair of properties.
override string ToString()
Returns the string representation of the properties.
The SimpleDatum class holds a data input within host memory.
int ItemCount
Returns the number of data items.
void SetData(SimpleDatum d)
Set the data of the current SimpleDatum by copying the data of another.
The DatasetDescriptor class describes a dataset which contains both a training data source and testin...
The SourceDescriptor class contains all information describing a data source.
The MyCaffeStreamDatabase provides a streaming data input source to MyCaffe gyms used as input for dy...
void Reset(int nStartOffset=0)
Reset the query to the start date used in Initialize, optionally with an offset from the start.
void Shutdown()
Shutdonw the streaming database.
void Initialize(QUERY_TYPE qt, string strSchema)
The Initialize method initializes the streaming database component, preparing it for data queries.
SimpleDatum Query(int nWait)
Query the next data in the streaming database.
byte[] ConvertOutput(float[] rg, out string type)
Converts the output values into the native type used by the first CustomQuery.
The DataGeneral Gym provides access to the MyCaffe Streaming Database with GENERAL query types.
void Close()
Shutdown and close the gym.
double TestingPercent
Returns the testinng percent of 0.2.
DatasetDescriptor GetDataset(DATA_TYPE dt, Log log=null)
Returns the dataset descriptor of the dynamic dataset produced by the Gym.
Tuple< State, double, bool > Step(int nAction, bool bGetLabel, PropertySet propExtra=null)
Step the gym one step in the data.
DATA_TYPE[] SupportedDataType
Returns the data types supported by this gym.
DataGeneralGym()
The constructor.
Tuple< Bitmap, SimpleDatum > Render(bool bShowUi, int nWidth, int nHeight, bool bGetAction)
Render the gym's current state on a bitmap and SimpleDatum.
Phase ActivePhase
Get/set the active phase under which the reset and next run.
void Initialize(Log log, PropertySet properties)
Initialize the gym with the specified properties.
Tuple< State, double, bool > Reset(bool bGetLabel, PropertySet props=null)
Reset the state of the gym.
bool RequiresDisplayImage
Returns true indicating that this Gym requires a display image.
Dictionary< string, int > GetActionSpace()
Returns the action space as a dictionary of name,actionid pairs.
Tuple< Bitmap, SimpleDatum > Render(bool bShowUi, int nWidth, int nHeight, double[] rgData, bool bGetAction)
Render the gyms specified data.
byte[] ConvertOutput(Stage stage, int nN, float[] rg, out string type)
Converts the output values into the native type used by the Gym during queries.
DATA_TYPE SelectedDataType
Returns the selected data type.
IXMyCaffeGym Clone(PropertySet properties=null)
Create a new copy of the gym.
string Name
Returns the gym's name.
void Dispose()
Release all resources used.
int UiDelay
Returns the delay to use (if any) when the user-display is visible.
The IXMyCaffeGym interface is used to interact with each Gym.
The IXMyCaffeGym interface is used to interact with each Gym.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Phase
Defines the Phase under which to run a Net.
GYM_TYPE
Defines the gym type (if any).
DATA_TYPE
Defines the gym data type.
Stage
Specifies the stage underwhich to run a custom trainer.
The MyCaffe.db.stream namespace contains all data streaming related classes.
QUERY_TYPE
Defines the query type to use.
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
GYM_SRC_TRAIN_ID
Defines the Standard GYM Training Data Source ID's.
GYM_DS_ID
Defines the Standard GYM Dataset ID's.
GYM_SRC_TEST_ID
Defines the Standard GYM Testing Data Source ID's.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...