twodlearn.convnet module¶
-
class
twodlearn.convnet.
Conv1x1Proj
(trainable=True, name=None, *args, **kwargs)[source]¶ Bases:
twodlearn.core.layers.Layer
Tdl autoinitialization with arguments:
-
kernel
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’]
-
units
[source]¶ (
InputArgument
) Number of output units (int).
-
bias
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’, ‘use_bias’]
-
activation
[source]
-
bias
[source] Autoinit with arguments [‘initializer’, ‘trainable’, ‘use_bias’]
-
call
(inputs)[source]¶ This is where the layer’s logic lives.
- Parameters
inputs – Input tensor, or list/tuple of input tensors.
**kwargs – Additional keyword arguments.
- Returns
A tensor or list/tuple of tensors.
-
compute_output_shape
(input_shape=None)[source]¶ Computes the output shape of the layer.
Assumes that the layer will be built to match that input shape provided.
- Parameters
input_shape – Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.
- Returns
An input shape tuple.
-
kernel
[source] Autoinit with arguments [‘initializer’, ‘trainable’]
-
units
[source] Number of output units (int).
-
use_bias
[source]
-
-
class
twodlearn.convnet.
Conv2DLayer
(trainable=True, name=None, *args, **kwargs)[source]¶ Bases:
twodlearn.core.layers.Layer
Tdl autoinitialization with arguments:
-
padding
[source]¶ (
InputArgument
) Padding for the convolution. It could be either ‘valid’ or ‘same’. Default is ‘valid’.
-
kernel
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’]
-
input_shape
[source]¶ (
InputArgument
) Input tensor shape: (n_samples, n_rows, n_cols, n_channels).
-
kernel_size
[source]¶ (
InputArgument
) Size of the convolution kernels. Must be a tuple/list of two elements (height, width)
-
dilation_rate
[source]¶ (
InputArgument
) Defaults to (1, 1).
-
filters
[source]¶ (
InputArgument
) Number of filters (int), equal to the number of output maps.
-
bias
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’, ‘use_bias’]
-
strides
[source]¶ (
InputArgument
) Convolution strides. Default is (1, 1).
-
bias
[source] Autoinit with arguments [‘initializer’, ‘trainable’, ‘use_bias’]
-
call
(inputs, *args, **kargs)[source]¶ This is where the layer’s logic lives.
- Parameters
inputs – Input tensor, or list/tuple of input tensors.
**kwargs – Additional keyword arguments.
- Returns
A tensor or list/tuple of tensors.
-
compute_output_shape
(input_shape=None)[source]¶ Computes the output shape of the layer.
Assumes that the layer will be built to match that input shape provided.
- Parameters
input_shape – Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.
- Returns
An input shape tuple.
-
dilation_rate
[source] Defaults to (1, 1).
-
filters
[source] Number of filters (int), equal to the number of output maps.
-
input_shape
[source] (n_samples, n_rows, n_cols, n_channels).
- Type
Input tensor shape
-
kernel
[source] Autoinit with arguments [‘initializer’, ‘trainable’]
-
kernel_size
[source] Size of the convolution kernels. Must be a tuple/list of two elements (height, width)
-
padding
[source] Padding for the convolution. It could be either ‘valid’ or ‘same’. Default is ‘valid’.
-
strides
[source] Convolution strides. Default is (1, 1).
-
use_bias
[source]
-
-
class
twodlearn.convnet.
Conv2DTranspose
(trainable=True, name=None, *args, **kwargs)[source]¶ Bases:
twodlearn.convnet.Conv2DLayer
Tdl autoinitialization with arguments:
-
padding
[source]¶ (
InputArgument
) Padding for the convolution. It could be either ‘valid’ or ‘same’. Default is ‘valid’.
-
kernel
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’]
-
input_shape
[source]¶ (
InputArgument
) Input tensor shape: (n_samples, n_rows, n_cols, n_channels).
-
kernel_size
[source]¶ (
InputArgument
) Size of the convolution kernels. Must be a tuple/list of two elements (height, width)
-
dilation_rate
[source]¶ (
InputArgument
) Defaults to (1, 1).
-
filters
[source]¶ (
InputArgument
) Number of filters (int), equal to the number of output maps.
-
bias
[source]¶ (
ParameterInit
) Autoinit with arguments [‘initializer’, ‘trainable’, ‘use_bias’]
-
strides
[source]¶ (
InputArgument
) Convolution strides. Default is (1, 1).
-
call
(inputs, *args, **kargs)[source]¶ This is where the layer’s logic lives.
- Parameters
inputs – Input tensor, or list/tuple of input tensors.
**kwargs – Additional keyword arguments.
- Returns
A tensor or list/tuple of tensors.
-
compute_output_shape
(input_shape)[source]¶ Computes the output shape of the layer.
Assumes that the layer will be built to match that input shape provided.
- Parameters
input_shape – Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.
- Returns
An input shape tuple.
-
kernel
[source] Autoinit with arguments [‘initializer’, ‘trainable’]
-
output_padding
[source]
-
-
twodlearn.convnet.
conv_output_length
(input_length, filter_size, padding, stride, dilation=1)[source]¶ Determines output length of a convolution given input length.
- Parameters
input_length (int) – integer.
filter_size (int) – integer.
padding (str) – one of “same”, “valid”, “full”, “causal”
stride (int) – integer.
dilation (int) – dilation rate, integer.
- Returns
the output length.
- Return type
int