| |
- Boost.Python.enum(builtins.int)
-
- dlprim._pydlprim.CalculationsMode
- dlprim._pydlprim.DataType
- Boost.Python.instance(builtins.object)
-
- dlprim._pydlprim.Adam
- dlprim._pydlprim.CommandQueue
- dlprim._pydlprim.Context
- dlprim._pydlprim.ExecutionContext
- dlprim._pydlprim.ModelBase
-
- dlprim._pydlprim.ONNXModel
- dlprim._pydlprim.Net
- dlprim._pydlprim.SGD
- dlprim._pydlprim.Shape
- dlprim._pydlprim.Tensor
- builtins.object
-
- dlprim.netconfig.NetConfig
class Adam(Boost.Python.instance) |
|
Adam optimizer |
|
- Method resolution order:
- Adam
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1, (Context)arg2) -> None :
Create optimizer from context
C++ signature :
void __init__(_object*,dlprim::Context {lvalue})
- __reduce__ = (...)
- apply(...)
- apply( (Adam)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
apply optimizer step - update all weights according to its status/gradients
C++ signature :
void apply(dlprim::solvers::Adam {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- init(...)
- init( (Adam)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
Prapare optimizer for network with execution_context, asynchronous
C++ signature :
void init(dlprim::solvers::Adam {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- step(...)
- step( (Adam)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
shortcut to
zero_grad(net,exe_ctx)
net.forward(exe_ctx)
net.backward(exe_ctx)
apply(net,exe_ctx)
C++ signature :
void step(dlprim::solvers::Adam {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- zero_grad(...)
- zero_grad( (Adam)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
zero all network gradients before accumulation
C++ signature :
void zero_grad(dlprim::solvers::Adam {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
Data descriptors defined here:
- beta1
- beta1, default 0.9
- beta2
- beta2, default 0.999
- eps
- epsilon, default 1e-8
- lr
- Lear rate, default 0.001
- weight_decay
- weight decay, default 0.0005
Data and other attributes defined here:
- __instance_size__ = 280
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class CalculationsMode(Boost.Python.enum) |
|
Train or Preduct mode selection |
|
- Method resolution order:
- CalculationsMode
- Boost.Python.enum
- builtins.int
- builtins.object
Data and other attributes defined here:
- PREDICT = dlprim._pydlprim.CalculationsMode.PREDICT
- TRAIN = dlprim._pydlprim.CalculationsMode.TRAIN
- names = {'PREDICT': dlprim._pydlprim.CalculationsMode.PREDICT, 'TRAIN': dlprim._pydlprim.CalculationsMode.TRAIN}
- values = {0: dlprim._pydlprim.CalculationsMode.TRAIN, 1: dlprim._pydlprim.CalculationsMode.PREDICT}
Methods inherited from Boost.Python.enum:
- __repr__(self, /)
- Return repr(self).
- __str__(self, /)
- Return str(self).
Data descriptors inherited from Boost.Python.enum:
- name
Methods inherited from builtins.int:
- __abs__(self, /)
- abs(self)
- __add__(self, value, /)
- Return self+value.
- __and__(self, value, /)
- Return self&value.
- __bool__(self, /)
- self != 0
- __ceil__(...)
- Ceiling of an Integral returns itself.
- __divmod__(self, value, /)
- Return divmod(self, value).
- __eq__(self, value, /)
- Return self==value.
- __float__(self, /)
- float(self)
- __floor__(...)
- Flooring an Integral returns itself.
- __floordiv__(self, value, /)
- Return self//value.
- __format__(...)
- default object formatter
- __ge__(self, value, /)
- Return self>=value.
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __getnewargs__(...)
- __gt__(self, value, /)
- Return self>value.
- __hash__(self, /)
- Return hash(self).
- __index__(self, /)
- Return self converted to an integer, if self is suitable for use as an index into a list.
- __int__(self, /)
- int(self)
- __invert__(self, /)
- ~self
- __le__(self, value, /)
- Return self<=value.
- __lshift__(self, value, /)
- Return self<<value.
- __lt__(self, value, /)
- Return self<value.
- __mod__(self, value, /)
- Return self%value.
- __mul__(self, value, /)
- Return self*value.
- __ne__(self, value, /)
- Return self!=value.
- __neg__(self, /)
- -self
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
- __or__(self, value, /)
- Return self|value.
- __pos__(self, /)
- +self
- __pow__(self, value, mod=None, /)
- Return pow(self, value, mod).
- __radd__(self, value, /)
- Return value+self.
- __rand__(self, value, /)
- Return value&self.
- __rdivmod__(self, value, /)
- Return divmod(value, self).
- __rfloordiv__(self, value, /)
- Return value//self.
- __rlshift__(self, value, /)
- Return value<<self.
- __rmod__(self, value, /)
- Return value%self.
- __rmul__(self, value, /)
- Return value*self.
- __ror__(self, value, /)
- Return value|self.
- __round__(...)
- Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(self, value, mod=None, /)
- Return pow(value, self, mod).
- __rrshift__(self, value, /)
- Return value>>self.
- __rshift__(self, value, /)
- Return self>>value.
- __rsub__(self, value, /)
- Return value-self.
- __rtruediv__(self, value, /)
- Return value/self.
- __rxor__(self, value, /)
- Return value^self.
- __sizeof__(...)
- Returns size in memory, in bytes
- __sub__(self, value, /)
- Return self-value.
- __truediv__(self, value, /)
- Return self/value.
- __trunc__(...)
- Truncating an Integral returns itself.
- __xor__(self, value, /)
- Return self^value.
- bit_length(...)
- int.bit_length() -> int
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
- conjugate(...)
- Returns self, the complex conjugate of any int.
- from_bytes(...) from builtins.type
- int.from_bytes(bytes, byteorder, *, signed=False) -> int
Return the integer represented by the given array of bytes.
The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
The byteorder argument determines the byte order used to represent the
integer. If byteorder is 'big', the most significant byte is at the
beginning of the byte array. If byteorder is 'little', the most
significant byte is at the end of the byte array. To request the native
byte order of the host system, use `sys.byteorder' as the byte order value.
The signed keyword-only argument indicates whether two's complement is
used to represent the integer.
- to_bytes(...)
- int.to_bytes(length, byteorder, *, signed=False) -> bytes
Return an array of bytes representing an integer.
The integer is represented using length bytes. An OverflowError is
raised if the integer is not representable with the given number of
bytes.
The byteorder argument determines the byte order used to represent the
integer. If byteorder is 'big', the most significant byte is at the
beginning of the byte array. If byteorder is 'little', the most
significant byte is at the end of the byte array. To request the native
byte order of the host system, use `sys.byteorder' as the byte order value.
The signed keyword-only argument determines whether two's complement is
used to represent the integer. If signed is False and a negative integer
is given, an OverflowError is raised.
Data descriptors inherited from builtins.int:
- denominator
- the denominator of a rational number in lowest terms
- imag
- the imaginary part of a complex number
- numerator
- the numerator of a rational number in lowest terms
- real
- the real part of a complex number
|
class CommandQueue(Boost.Python.instance) |
|
Wrapper of cl::CommandQueue |
|
- Method resolution order:
- CommandQueue
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
- __reduce__ = (...)
Data and other attributes defined here:
- __instance_size__ = 24
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class Context(Boost.Python.instance) |
|
Context of computations - represents OpenCL device, platform and context, it is passed to all objectthat are created during the process |
|
- Method resolution order:
- Context
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
__init__( (object)arg1, (str)arg2) -> None :
Create context by name, which is either `cpu` or P:D where P is platform id (number) and D is device id (number)
C++ signature :
void __init__(_object*,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- __reduce__ = (...)
- make_execution_context(...)
- make_execution_context( (Context)arg1, (object)arg2) -> ExecutionContext :
Creates execution context - wrapper of OpenCL command queue
C++ signature :
dlprim::ExecutionContext make_execution_context(dlprim::Context {lvalue},unsigned long)
Data descriptors defined here:
- is_cpu_context
- returns true if context is CPU Context
- is_opencl_context
- returns true if the context is OpenCL context
- name
- Get name of the context - device name and platform readable to human
Data and other attributes defined here:
- __instance_size__ = 136
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class DataType(Boost.Python.enum) |
|
Type of tensor data |
|
- Method resolution order:
- DataType
- Boost.Python.enum
- builtins.int
- builtins.object
Data and other attributes defined here:
- bfloat16 = dlprim._pydlprim.DataType.bfloat16
- float32 = dlprim._pydlprim.DataType.float32
- half = dlprim._pydlprim.DataType.half
- int16 = dlprim._pydlprim.DataType.int16
- int32 = dlprim._pydlprim.DataType.int32
- int64 = dlprim._pydlprim.DataType.int64
- int8 = dlprim._pydlprim.DataType.int8
- names = {'bfloat16': dlprim._pydlprim.DataType.bfloat16, 'float32': dlprim._pydlprim.DataType.float32, 'half': dlprim._pydlprim.DataType.half, 'int16': dlprim._pydlprim.DataType.int16, 'int32': dlprim._pydlprim.DataType.int32, 'int64': dlprim._pydlprim.DataType.int64, 'int8': dlprim._pydlprim.DataType.int8, 'uint16': dlprim._pydlprim.DataType.uint16, 'uint32': dlprim._pydlprim.DataType.uint32, 'uint64': dlprim._pydlprim.DataType.uint64, ...}
- uint16 = dlprim._pydlprim.DataType.uint16
- uint32 = dlprim._pydlprim.DataType.uint32
- uint64 = dlprim._pydlprim.DataType.uint64
- uint8 = dlprim._pydlprim.DataType.uint8
- values = {2: dlprim._pydlprim.DataType.half, 3: dlprim._pydlprim.DataType.float32, 10: dlprim._pydlprim.DataType.bfloat16, 17: dlprim._pydlprim.DataType.int8, 18: dlprim._pydlprim.DataType.int16, 19: dlprim._pydlprim.DataType.int32, 20: dlprim._pydlprim.DataType.int64, 25: dlprim._pydlprim.DataType.uint8, 26: dlprim._pydlprim.DataType.uint16, 27: dlprim._pydlprim.DataType.uint32, ...}
Methods inherited from Boost.Python.enum:
- __repr__(self, /)
- Return repr(self).
- __str__(self, /)
- Return str(self).
Data descriptors inherited from Boost.Python.enum:
- name
Methods inherited from builtins.int:
- __abs__(self, /)
- abs(self)
- __add__(self, value, /)
- Return self+value.
- __and__(self, value, /)
- Return self&value.
- __bool__(self, /)
- self != 0
- __ceil__(...)
- Ceiling of an Integral returns itself.
- __divmod__(self, value, /)
- Return divmod(self, value).
- __eq__(self, value, /)
- Return self==value.
- __float__(self, /)
- float(self)
- __floor__(...)
- Flooring an Integral returns itself.
- __floordiv__(self, value, /)
- Return self//value.
- __format__(...)
- default object formatter
- __ge__(self, value, /)
- Return self>=value.
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __getnewargs__(...)
- __gt__(self, value, /)
- Return self>value.
- __hash__(self, /)
- Return hash(self).
- __index__(self, /)
- Return self converted to an integer, if self is suitable for use as an index into a list.
- __int__(self, /)
- int(self)
- __invert__(self, /)
- ~self
- __le__(self, value, /)
- Return self<=value.
- __lshift__(self, value, /)
- Return self<<value.
- __lt__(self, value, /)
- Return self<value.
- __mod__(self, value, /)
- Return self%value.
- __mul__(self, value, /)
- Return self*value.
- __ne__(self, value, /)
- Return self!=value.
- __neg__(self, /)
- -self
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
- __or__(self, value, /)
- Return self|value.
- __pos__(self, /)
- +self
- __pow__(self, value, mod=None, /)
- Return pow(self, value, mod).
- __radd__(self, value, /)
- Return value+self.
- __rand__(self, value, /)
- Return value&self.
- __rdivmod__(self, value, /)
- Return divmod(value, self).
- __rfloordiv__(self, value, /)
- Return value//self.
- __rlshift__(self, value, /)
- Return value<<self.
- __rmod__(self, value, /)
- Return value%self.
- __rmul__(self, value, /)
- Return value*self.
- __ror__(self, value, /)
- Return value|self.
- __round__(...)
- Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(self, value, mod=None, /)
- Return pow(value, self, mod).
- __rrshift__(self, value, /)
- Return value>>self.
- __rshift__(self, value, /)
- Return self>>value.
- __rsub__(self, value, /)
- Return value-self.
- __rtruediv__(self, value, /)
- Return value/self.
- __rxor__(self, value, /)
- Return value^self.
- __sizeof__(...)
- Returns size in memory, in bytes
- __sub__(self, value, /)
- Return self-value.
- __truediv__(self, value, /)
- Return self/value.
- __trunc__(...)
- Truncating an Integral returns itself.
- __xor__(self, value, /)
- Return self^value.
- bit_length(...)
- int.bit_length() -> int
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
- conjugate(...)
- Returns self, the complex conjugate of any int.
- from_bytes(...) from builtins.type
- int.from_bytes(bytes, byteorder, *, signed=False) -> int
Return the integer represented by the given array of bytes.
The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
The byteorder argument determines the byte order used to represent the
integer. If byteorder is 'big', the most significant byte is at the
beginning of the byte array. If byteorder is 'little', the most
significant byte is at the end of the byte array. To request the native
byte order of the host system, use `sys.byteorder' as the byte order value.
The signed keyword-only argument indicates whether two's complement is
used to represent the integer.
- to_bytes(...)
- int.to_bytes(length, byteorder, *, signed=False) -> bytes
Return an array of bytes representing an integer.
The integer is represented using length bytes. An OverflowError is
raised if the integer is not representable with the given number of
bytes.
The byteorder argument determines the byte order used to represent the
integer. If byteorder is 'big', the most significant byte is at the
beginning of the byte array. If byteorder is 'little', the most
significant byte is at the end of the byte array. To request the native
byte order of the host system, use `sys.byteorder' as the byte order value.
The signed keyword-only argument determines whether two's complement is
used to represent the integer. If signed is False and a negative integer
is given, an OverflowError is raised.
Data descriptors inherited from builtins.int:
- denominator
- the denominator of a rational number in lowest terms
- imag
- the imaginary part of a complex number
- numerator
- the numerator of a rational number in lowest terms
- real
- the real part of a complex number
|
class ModelBase(Boost.Python.instance) |
| |
- Method resolution order:
- ModelBase
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- Raises an exception
This class cannot be instantiated from Python
- __reduce__ = (...)
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class Net(Boost.Python.instance) |
|
Central class that represents network for training and inference
General workflow for network preparaiton is following:
ctx = dlprim.Context(device_name) # general context
exe_context = ctx.make_execution_context() # create execution queue
net = dlprim.Net(ctx) # create network for context
net.mode = dlprim.TRAIN # set mode to training
net.load_from_json(net_config) # configure graph
net.setup() # allocate all tensors for graph
net.initialize_parameters(exe_context) # initialize parameters
Than the main training loop is:
opt = dlprim.Adam(ctx) # create optilized
opt.init(net,exe_context) # initialize it
dev_data = net.tensor("data")
dev_labals = net.tensor("labels")
dev_loss = net.tensor("loss")
for each batch:
dev_data.to_device(my_data,exe_context)
dev_loss.to_device(my_labels,exe_context)
opt.step(net,exe_context)
# asynchronous execution started
# now we can prepara next batch
my_data = my_next_data
my_labels = my_next_labels
loss.to_host(my_loss,exe_context)
# ^ sync op - so we wait for completion
print(my_loss)
For inference it is following:
net = dlprim.Net(ctx) # create network for context
net.load_from_json_file(path_net_config_js) # configure graph
net.setup() # allocate all tensors for graph
net.load_parameters(path_to_weights) # initialize parameters
# coyp input data
net.tensors("data").to_device(my_data,exe_context)
net.forward(exe_context) # start computing - async
net.tensors(my_prob,exe_context) # get results
Network that created in training mode can switch to inference most
and back by setting mode propery |
|
- Method resolution order:
- Net
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1, (Context)arg2) -> None :
Create a network for a context
C++ signature :
void __init__(_object*,dlprim::Context {lvalue})
- __reduce__ = (...)
- backward(...)
- backward( (Net)arg1, (ExecutionContext)arg2) -> None :
Enqueue network backpropogation to the execution context and return
C++ signature :
void backward(dlprim::Net {lvalue},dlprim::ExecutionContext)
- forward(...)
- forward( (Net)arg1, (ExecutionContext)arg2) -> None :
Enqueue network forward propogation to the execution context and return
C++ signature :
void forward(dlprim::Net {lvalue},dlprim::ExecutionContext)
- initialize_parameters(...)
- initialize_parameters( (Net)arg1, (ExecutionContext)arg2) -> None :
Enqueue network parameters initialization with default values for training
C++ signature :
void initialize_parameters(dlprim::Net {lvalue},dlprim::ExecutionContext)
- load_from_json(...)
- load_from_json( (Net)arg1, (str)arg2) -> None :
Load network definition from json text
C++ signature :
void load_from_json(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- load_from_json_file(...)
- load_from_json_file( (Net)arg1, (str)arg2) -> None :
Load network definition from json file
C++ signature :
void load_from_json_file(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- load_model(...)
- load_model( (Net)arg1, (ModelBase)arg2) -> None :
Load external model
C++ signature :
void load_model(dlprim::Net {lvalue},dlprim::ModelBase {lvalue})
- load_parameters(...)
- load_parameters( (Net)arg1, (str)arg2, (object)arg3) -> None :
Load parameters from file, either HDF5 or DLP format. If second argument - ignore missing parameter, if true and parameter value does not exists in file it isn't considered a error, useful for transfer learning
C++ signature :
void load_parameters(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,bool)
load_parameters( (Net)arg1, (str)arg2) -> None :
same as self.load_parameters(file,False)
C++ signature :
void load_parameters(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- param(...)
- param( (Net)arg1, (str)arg2) -> Tensor :
Get network parameter by name
C++ signature :
dlprim::Tensor param(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- reshape(...)
- reshape( (Net)arg1) -> None :
reshape all tensors in network after reshaping the input data
C++ signature :
void reshape(dlprim::Net {lvalue})
- save_parameters(...)
- save_parameters( (Net)arg1, (str)arg2) -> None :
save nework parameters to DLP format
C++ signature :
void save_parameters(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- save_parameters_to_hdf5(...)
- save_parameters_to_hdf5( (Net)arg1, (str)arg2) -> None :
save nework parameters to HDF5 format
C++ signature :
void save_parameters_to_hdf5(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- setup(...)
- setup( (Net)arg1) -> None :
Allocate all tensors and prepare network data
C++ signature :
void setup(dlprim::Net {lvalue})
- tensor(...)
- tensor( (Net)arg1, (str)arg2) -> Tensor :
Get tensor by name
C++ signature :
dlprim::Tensor tensor(dlprim::Net {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
Data descriptors defined here:
- input_names
- List of all input tensor names
- keep_intermediate_tensors
- set to true to keed intermediate results for debugging. Default is false - optimise memory use and reuse intermediate memory chunks
- mode
- Property for changing network behavior, by default network is created for PREDICT mode for inference, if you want to train network, set to TRAIN before calling setup
note: network created for inference can't be switched to train mode, but network created for training can work in both PREDICT and TRAIN mode
- output_names
- List of all output tensor names
Data and other attributes defined here:
- __instance_size__ = 752
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class NetConfig(builtins.object) |
|
Helper class that allows generation of network definitions in JSON format |
|
Methods defined here:
- __init__(self)
- Create an empty network
- __str__(self)
- returns self.to_str()
- add(self, op, name=None, inputs=None, outputs=None, options=None)
- Add new operator to network, it is appended to the end.
Parameters:
op: string operator type, for example Activation
name: string a unique name of the operator, if not provided it is auto-generated
inputs: string or list of strings operator inputs, if not provided it takes outputs of the provious operator or network input
in no operator exits (must be single input)
outputs: string or list of strings, if not defined single output name is autogeneratord
options: dict - dictionart of options for operator op.
- add_input(self, name, shape, dtype='float')
- Define network input tensor
Parameters:
name: string name of input tensor
shape: list/tuple of integers shape of input tensor
dtype: type of input tensor: float, int32, etc.
- save(self, path)
- Save network definition to file named path
- set_outputs(self, outputs)
- Specify network outputs, outputs need to be list of strings that define output tensor names
for example ["prob","loss"]
Note: if no output is set the output of the last operator is considered network output
- to_json(self)
- Return json representaion of the network, note it is python dictionary that can be serialized to json
- to_str(self)
- Create json representation of the network as string
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ONNXModel(ModelBase) |
|
ONNX Model parser and importer, once it is loaded, Net.load can be called |
|
- Method resolution order:
- ONNXModel
- ModelBase
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
__init__( (object)arg1) -> None :
Empty
C++ signature :
void __init__(_object*)
- __reduce__ = (...)
- load(...)
- load( (ONNXModel)arg1, (str)arg2) -> None :
Load model from file
C++ signature :
void load(dlprim::ONNXModel {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
Data descriptors defined here:
- network
- Export network as string
Data and other attributes defined here:
- __instance_size__ = 32
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class SGD(Boost.Python.instance) |
|
SGD optimizer |
|
- Method resolution order:
- SGD
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1, (Context)arg2) -> None :
Create SDG for context
C++ signature :
void __init__(_object*,dlprim::Context {lvalue})
- __reduce__ = (...)
- apply(...)
- apply( (SGD)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
apply optimizer step - update all weights according to its status/gradients
C++ signature :
void apply(dlprim::solvers::SGD {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- init(...)
- init( (SGD)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
Prapare optimizer for network with execution_context, asynchronous
C++ signature :
void init(dlprim::solvers::SGD {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- step(...)
- step( (SGD)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
shortcut to
zero_grad(net,exe_ctx)
net.forward(exe_ctx)
net.backward(exe_ctx)
apply(net,exe_ctx)
C++ signature :
void step(dlprim::solvers::SGD {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
- zero_grad(...)
- zero_grad( (SGD)arg1, (Net)arg2, (ExecutionContext)arg3) -> None :
zero all network gradients before accumulation
C++ signature :
void zero_grad(dlprim::solvers::SGD {lvalue},dlprim::Net {lvalue},dlprim::ExecutionContext)
Data descriptors defined here:
- lr
- learn rate, default 0.1
- momentum
- momenutum, default 0.9
- weight_decay
- weight decay, default 0.0005
Data and other attributes defined here:
- __instance_size__ = 464
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class Shape(Boost.Python.instance) |
|
Shape of tensor object |
|
- Method resolution order:
- Shape
- Boost.Python.instance
- builtins.object
Methods defined here:
- __getitem__(...)
- __getitem__( (Shape)arg1, (object)arg2) -> int :
get size for a dimention
C++ signature :
unsigned long __getitem__(dlprim::Shape,int)
- __init__(...)
- __init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
__init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
__init__( (object)arg1, (object)arg2) -> None :
C++ signature :
void __init__(_object*,unsigned long)
__init__( (object)arg1, (object)arg2, (object)arg3) -> None :
C++ signature :
void __init__(_object*,unsigned long,unsigned long)
__init__( (object)arg1, (object)arg2, (object)arg3, (object)arg4) -> None :
C++ signature :
void __init__(_object*,unsigned long,unsigned long,unsigned long)
__init__( (object)arg1, (object)arg2, (object)arg3, (object)arg4, (object)arg5) -> None :
C++ signature :
void __init__(_object*,unsigned long,unsigned long,unsigned long,unsigned long)
- __len__(...)
- __len__( (Shape)arg1) -> int :
get number of dimentions of the shape
C++ signature :
int __len__(dlprim::Shape {lvalue})
- __reduce__ = (...)
- __str__(...)
- __str__( (Shape)arg1) -> str :
format as string
C++ signature :
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > __str__(dlprim::Shape)
Data descriptors defined here:
- total_size
- get total count of items in shape, for example for Shape(2,3) it is 6
Data and other attributes defined here:
- __instance_size__ = 64
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
|
class Tensor(Boost.Python.instance) |
|
Class that represents a tensor |
|
- Method resolution order:
- Tensor
- Boost.Python.instance
- builtins.object
Methods defined here:
- __init__(...)
- __init__( (object)arg1) -> None :
C++ signature :
void __init__(_object*)
__init__( (object)arg1) -> None :
Create Null tensor
C++ signature :
void __init__(_object*)
__init__( (object)arg1, (Context)arg2, (Shape)arg3) -> None :
Create float32 tensor for context of given shape
C++ signature :
void __init__(_object*,dlprim::Context {lvalue},dlprim::Shape)
__init__( (object)arg1, (Context)arg2, (Shape)arg3, (DataType)arg4) -> None :
Create a tensor for context of given shape and type
C++ signature :
void __init__(_object*,dlprim::Context {lvalue},dlprim::Shape,dlprim::DataType)
- __reduce__ = (...)
- reshape(...)
- reshape( (Tensor)arg1, (Shape)arg2) -> None :
Change shape of the tensor - its total_size of new shape needs to be <= of current total size
C++ signature :
void reshape(dlprim::Tensor {lvalue},dlprim::Shape)
- to_device(...)
- to_device( (Tensor)arg1, (object)arg2, (ExecutionContext)arg3) -> None :
Enqueue copy tensor to defice from a numpy array and wait for completion. numpy array must have same shape, type as tensor and must be contiguous, operation is always synchronous
C++ signature :
void to_device(dlprim::Tensor {lvalue},boost::python::numpy::ndarray,dlprim::ExecutionContext)
- to_host(...)
- to_host( (Tensor)arg1, (object)arg2, (ExecutionContext)arg3) -> None :
Enqueue copy tensor to host to a numpy array and wait for completion. numpy array must have same shape, type as tensor and must be contiguous, operation is always synchronous
C++ signature :
void to_host(dlprim::Tensor {lvalue},boost::python::numpy::ndarray,dlprim::ExecutionContext)
Data descriptors defined here:
- dtype
- Returns tensor type
- shape
- Returns tensor shape
Data and other attributes defined here:
- __instance_size__ = 80
Methods inherited from Boost.Python.instance:
- __new__(*args, **kwargs) from Boost.Python.class
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from Boost.Python.instance:
- __dict__
- __weakref__
| |