Interactive Training using Python¶
Layer
class (layer.py) has the following methods for an interactive training.
For the basic usage of Python binding features, please refer to python.md.
ComputeFeature(self, *srclys)
- This method creates and sets up singa::Layer and maintains its source layers, then call singa::Layer::ComputeFeature(...) for data transformation.
*srclys
: (an arbtrary number of) source layers
ComputeGradient(self)
- This method creates calls singa::Layer::ComputeGradient(...) for gradient computation.
GetParams(self)
- This method calls singa::Layer::GetParam() to retrieve parameter values of the layer. Currently, it returns weight and bias. Each parameter is a 2D numpy array.
SetParams(self, *params)
- This method sets parameter values of the layer.
*params
: (an arbitrary number of) parameters, each of which is a 2D numpy array. Typically, it sets weight and bias, 2D numpy array.
Dummy
class is a subclass of Layer
, which is provided to fetch input data and/or label information.
Specifically, it creates singa::DummyLayer.
Feed(self, shape, data, aux_data)
- This method sets input data and/or auxiary data such as labels.
shape
: the shape (width and height) of datasetdata
: input datasetaux_data
: auxiary dataset (e.g., labels)
In addition, Dummy
class has two subclasses named ImageInput
and LabelInput
.
ImageInput
class will take three arguments as follows.__init__(self, height=None, width=None, nb_channel=1)
Both
ImageInput
andLabelInput
classes have their own Feed method to call Feed of Dummy class.Feed(self, data)