OMLT Layers
Neural network layer classes.
- class omlt.neuralnet.layer.ConvLayer(input_size, output_size, strides, kernel, *, activation=None, input_index_mapper=None)[source]
Bases:
omlt.neuralnet.layer.Layer
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
- property kernel_shape
- kernel_with_input_indexes(out_d, out_r, out_c)[source]
Returns an iterator over the kernel value and input index for the output at index (out_d, out_r, out_c).
- property strides
- class omlt.neuralnet.layer.DenseLayer(input_size, output_size, weights, biases, *, activation=None, input_index_mapper=None)[source]
Bases:
omlt.neuralnet.layer.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
- property 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
- property output_size
- class omlt.neuralnet.layer.InputLayer(size)[source]
Bases:
omlt.neuralnet.layer.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 (tuple) – size of the layer input
output_size (tuple) – 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(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