MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.gym.python.MyCaffePythonGym Class Reference

The MyCaffePythonGym class provides a simple interface that can easily be used from within Python. More...

Inheritance diagram for MyCaffe.gym.python.MyCaffePythonGym:
MyCaffe.gym.IXMyCaffeGymUiCallback

Public Member Functions

 MyCaffePythonGym ()
 The constructor. More...
 
void Dispose ()
 Release resources used. More...
 
int Initialize (string strGym, string strParam)
 The Initialize method loads the gym specified. More...
 
void SetActionDistributions (double[][] rgrg)
 Set the action distribution for display. More...
 
List< List< List< double > > > GetDataAs3D (bool bGrayscale=false, double dfScale=1, SimpleDatum sd=null)
 Returns the data int a 3D form compatible with CV2. More...
 
List< List< List< double > > > GetDataAsStacked3D (bool bReset, int nFrames=4, int nStacks=4, bool bGrayscale=true, double dfScale=1)
 Returns stacked data in a 3D form compatible with CV2. More...
 
CurrentState Reset (PropertySet props=null)
 Resets the gym to its initial state. More...
 
CurrentState Step (int nAction, int nSteps=1, PropertySet props=null)
 Steps the gym one or more steps with a given action. More...
 
DatasetDescriptor GetDataset (DATA_TYPE type)
 Returns the dataset descriptor of the Gym. More...
 
void OpenUi (bool bStartRecording=false)
 The OpenUi method opens the user interface to visualize the gym as it progresses. More...
 
void CloseUi ()
 The CloseUi method closes the user interface if it is open. More...
 
void Closing ()
 The Closing method is a call-back method called when the gym closes. More...
 

Properties

string Name [get]
 Returns the name of the gym. More...
 
int[] Actions [get]
 Returns the action values More...
 
string[] ActionNames [get]
 Returns the action names More...
 
bool? IsTerminal [get]
 Returns the terminal state from the last state. More...
 
double? Reward [get]
 Returns the reward from the last state. More...
 
List< double >? Data [get]
 Returns the data from the last state. More...
 

Detailed Description

The MyCaffePythonGym class provides a simple interface that can easily be used from within Python.

To use within Python first install the PythonNet package with the command:

pip install pythonnet

Next, from within python use the following code to access the MyCaffePythonGym.

import clr
clr.AddReference('path\\MyCaffe.gym.python.dll')
from MyCaffe.gym.python import *
gym.Initialize('ATARI', 'FrameSkip=4;GameROM=C:\\Program~Files\\SignalPop\\AI~Designer\\roms\\pong.bin')
gym.OpenUi()
gym.Step(action, 1)
gym.CloseUi();
void CloseUi()
The CloseUi method closes the user interface if it is open.
void OpenUi(bool bStartRecording=false)
The OpenUi method opens the user interface to visualize the gym as it progresses.
int Initialize(string strGym, string strParam)
The Initialize method loads the gym specified.
CurrentState Step(int nAction, int nSteps=1, PropertySet props=null)
Steps the gym one or more steps with a given action.
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12

NOTE: Using the OpenUi function requires that a UI service host is already running. The MyCaffe Test Application automatically provides a service host - just run this application before running your Python script and the test application will then handle the user interface display.

To get the latest MyCaffe Test Application, see https://github.com/MyCaffe/MyCaffe/releases

Definition at line 45 of file MyCaffePythonGym.cs.

Constructor & Destructor Documentation

◆ MyCaffePythonGym()

MyCaffe.gym.python.MyCaffePythonGym.MyCaffePythonGym ( )

The constructor.

Definition at line 61 of file MyCaffePythonGym.cs.

Member Function Documentation

◆ CloseUi()

void MyCaffe.gym.python.MyCaffePythonGym.CloseUi ( )

The CloseUi method closes the user interface if it is open.

Definition at line 605 of file MyCaffePythonGym.cs.

◆ Closing()

void MyCaffe.gym.python.MyCaffePythonGym.Closing ( )

The Closing method is a call-back method called when the gym closes.

Implements MyCaffe.gym.IXMyCaffeGymUiCallback.

Definition at line 619 of file MyCaffePythonGym.cs.

◆ Dispose()

void MyCaffe.gym.python.MyCaffePythonGym.Dispose ( )

Release resources used.

Definition at line 68 of file MyCaffePythonGym.cs.

◆ GetDataAs3D()

List< List< List< double > > > MyCaffe.gym.python.MyCaffePythonGym.GetDataAs3D ( bool  bGrayscale = false,
double  dfScale = 1,
SimpleDatum  sd = null 
)

Returns the data int a 3D form compatible with CV2.

Parameters
bGrayscaleOptionally, specifies to return gray scale data (one channel).
dfScaleOptionally, specifies the scale to apply to each item.
sdOptionally, specifies the data.
Returns
The data is returned as a multi-dimensional array.

Definition at line 212 of file MyCaffePythonGym.cs.

◆ GetDataAsStacked3D()

List< List< List< double > > > MyCaffe.gym.python.MyCaffePythonGym.GetDataAsStacked3D ( bool  bReset,
int  nFrames = 4,
int  nStacks = 4,
bool  bGrayscale = true,
double  dfScale = 1 
)

Returns stacked data in a 3D form compatible with CV2.

Parameters
bResetSpecifies to reset the stack or not.
nFramesOptionally, specifies the number of frames (default = 4).
nStacksOptionally, specifies the number of stacks (default = 4).
bGrayscaleOptionally, specifies to return gray scale data (default = true, one channel).
dfScaleOptionally, specifies the scale to apply to each item (default = 1.0).
Returns
The data is returned as a multi-dimensional array.

Definition at line 341 of file MyCaffePythonGym.cs.

◆ GetDataset()

DatasetDescriptor MyCaffe.gym.python.MyCaffePythonGym.GetDataset ( DATA_TYPE  type)

Returns the dataset descriptor of the Gym.

Parameters
typeSpecifies the dataset type.
Returns
The DatasetDescriptor for the Gym is returned.

Definition at line 573 of file MyCaffePythonGym.cs.

◆ Initialize()

int MyCaffe.gym.python.MyCaffePythonGym.Initialize ( string  strGym,
string  strParam 
)

The Initialize method loads the gym specified.

Parameters
strGymSpecifies the name of the gym to load.
strParamSpecifies the semi-colon separated parameters passed to the gym.
Returns
0 is returned on success.

The following gyms are supported: 'ATARI', 'Cart-Pole'

Definition at line 96 of file MyCaffePythonGym.cs.

◆ OpenUi()

void MyCaffe.gym.python.MyCaffePythonGym.OpenUi ( bool  bStartRecording = false)

The OpenUi method opens the user interface to visualize the gym as it progresses.

Parameters
bStartRecordingOptionally, specifies to open with recording on.

Definition at line 585 of file MyCaffePythonGym.cs.

◆ Reset()

CurrentState MyCaffe.gym.python.MyCaffePythonGym.Reset ( PropertySet  props = null)

Resets the gym to its initial state.

Parameters
propsOptionally, specifies a set of properties to use to reset the gym.
Returns
A tuple containing a double[] with the data, a double with the reward and a bool with the terminal state is returned.

Definition at line 378 of file MyCaffePythonGym.cs.

◆ SetActionDistributions()

void MyCaffe.gym.python.MyCaffePythonGym.SetActionDistributions ( double  rgrg[][])

Set the action distribution for display.

Parameters
rgrgSpecifies the action distribution data where a distribution is provided per action.

Definition at line 130 of file MyCaffePythonGym.cs.

◆ Step()

CurrentState MyCaffe.gym.python.MyCaffePythonGym.Step ( int  nAction,
int  nSteps = 1,
PropertySet  props = null 
)

Steps the gym one or more steps with a given action.

Parameters
nActionSpecifies the action to run.
nStepsSpecifies the number of steps to run the action.
propsOptionally, specifies properties that may include the 'override_prediction' values used to set the prediction override.
Returns
A tuple containing a double[] with the data, a double with the reward and a bool with the terminal state is returned.

Definition at line 421 of file MyCaffePythonGym.cs.

Property Documentation

◆ ActionNames

string [] MyCaffe.gym.python.MyCaffePythonGym.ActionNames
get

Returns the action names

Definition at line 162 of file MyCaffePythonGym.cs.

◆ Actions

int [] MyCaffe.gym.python.MyCaffePythonGym.Actions
get

Returns the action values

Definition at line 138 of file MyCaffePythonGym.cs.

◆ Data

List<double>? MyCaffe.gym.python.MyCaffePythonGym.Data
get

Returns the data from the last state.

Definition at line 200 of file MyCaffePythonGym.cs.

◆ IsTerminal

bool? MyCaffe.gym.python.MyCaffePythonGym.IsTerminal
get

Returns the terminal state from the last state.

Definition at line 184 of file MyCaffePythonGym.cs.

◆ Name

string MyCaffe.gym.python.MyCaffePythonGym.Name
get

Returns the name of the gym.

Definition at line 115 of file MyCaffePythonGym.cs.

◆ Reward

double? MyCaffe.gym.python.MyCaffePythonGym.Reward
get

Returns the reward from the last state.

Definition at line 192 of file MyCaffePythonGym.cs.


The documentation for this class was generated from the following file: