OMLT Layers
Neural network layer classes.
- class omlt.neuralnet.layer.ConvLayer2D(input_size, output_size, strides, kernel, *, activation=None, input_index_mapper=None)[source]
Bases:
Layer2D
Two-dimensional convolutional layer.
- Parameters:
input_size (tuple) – the size of the input.
output_size (tuple) – the size of the output..
strides (matrix-like) – stride of the cross-correlation kernel.
kernel (matrix-like) – the cross-correlation kernel.
activation (str or None) – activation function name
input_index_mapper (IndexMapper or None) – map indexes from this layer index to the input layer index size
- property kernel
Return the cross-correlation kernel
- property kernel_depth
Return the depth of the cross-correlation kernel
- property kernel_shape
Return the shape of the cross-correlation kernel
- class omlt.neuralnet.layer.DenseLayer(input_size, output_size, weights, biases, *, activation=None, input_index_mapper=None)[source]
Bases:
Layer
Dense layer implementing output = activation(dot(input, weights) + biases).
- Parameters:
input_size (tuple) – the size of the input.
output_size (tuple) – the size of the output.
weight (matrix-like) – the weight matrix.
biases (array-like) – the biases.
activation (str or None) – activation function name
input_index_mapper (IndexMapper or None) – map indexes from this layer index to the input layer index size
- property biases
Return the vector of node biases
- property weights
Return the matrix of node weights
- class omlt.neuralnet.layer.IndexMapper(input_size, output_size)[source]
Bases:
object
Map indexes from one layer to the other.
- Parameters:
- property input_size
Return the size of the input tensor
- property output_size
Return the size of the output tensor
- class omlt.neuralnet.layer.InputLayer(size)[source]
Bases:
Layer
The first layer in any network.
- Parameters:
size (tuple) – the size of the input.
- class omlt.neuralnet.layer.Layer(input_size, output_size, *, activation=None, input_index_mapper=None)[source]
Bases:
object
Base layer class.
- Parameters:
input_size (list) – size of the layer input
output_size (list) – size of the layer output
activation (str or None) – activation function name
input_index_mapper (IndexMapper or None) – map indexes from this layer index to the input layer index size
- property activation
Return the activation function
- eval_single_layer(x)[source]
Evaluate the layer at x.
- Parameters:
x (array-like) – the input tensor. Must have size self.input_size.
- property input_index_mapper
Return the index mapper
- property input_indexes
Return a list of the input indexes
- property input_indexes_with_input_layer_indexes
Return an iterator generating a tuple of local and input indexes.
Local indexes are indexes over the elements of the current layer. Input indexes are indexes over the elements of the previous layer.
- property input_size
Return the size of the input tensor
- property output_indexes
Return a list of the output indexes
- property output_size
Return the size of the output tensor
- class omlt.neuralnet.layer.Layer2D(input_size, output_size, strides, *, activation=None, input_index_mapper=None)[source]
Bases:
Layer
Abstract two-dimensional layer that downsamples values in a kernel to a single value.
- Parameters:
input_size (tuple) – the size of the input.
output_size (tuple) – the size of the output.
strides (matrix-like) – stride of the kernel.
activation (str or None) – activation function name
input_index_mapper (IndexMapper or None) – map indexes from this layer index to the input layer index size
- get_input_index(out_index, kernel_index)[source]
Returns the input index corresponding to the output at out_index and the kernel index kernel_index.
- property kernel_depth
Return the depth of the kernel
- kernel_index_with_input_indexes(out_d, out_r, out_c)[source]
Returns an iterator over the index within the kernel and input index for the output at index (out_d, out_r, out_c).
- property kernel_shape
Return the shape of the kernel
- property strides
Return the stride of the layer
- class omlt.neuralnet.layer.PoolingLayer2D(input_size, output_size, strides, pool_func_name, kernel_shape, kernel_depth, *, activation=None, input_index_mapper=None)[source]
Bases:
Layer2D
Two-dimensional pooling layer.
- Parameters:
input_size (tuple) – the size of the input.
output_size (tuple) – the size of the output.
strides (matrix-like) – stride of the kernel.
pool_func (str) – name of function used to pool values in a kernel to a single value.
transpose (bool) – True iff input matrix is accepted in transposed (i.e. column-major) form.
activation (str or None) – activation function name
input_index_mapper (IndexMapper or None) – map indexes from this layer index to the input layer index size
- property kernel_depth
Return the depth of the kernel
- property kernel_shape
Return the shape of the kernel