deepcell.layers
Custom Layers
location
Layers to encode location data
- class deepcell.layers.location.Location2D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Location Layer for 2D cartesian coordinate locations.
- Parameters:
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
- class deepcell.layers.location.Location3D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Location Layer for 3D cartesian coordinate locations.
- Parameters:
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
normalization
Layers to noramlize input images for 2D and 3D images
- class deepcell.layers.normalization.ImageNormalization2D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Image Normalization layer for 2D data.
- Parameters:
norm_method (str) – Normalization method to use, one of: “std”, “max”, “whole_image”, None.
filter_size (int) – The length of the convolution window.
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.activation (function) – Activation function to use. If you don’t specify anything, no activation is applied (ie. “linear” activation:
a(x) = x
).use_bias (bool) – Whether the layer uses a bias.
kernel_initializer (function) – Initializer for the
kernel
weights matrix, used for the linear transformation of the inputs.bias_initializer (function) – Initializer for the bias vector. If None, the default initializer will be used.
kernel_regularizer (function) – Regularizer function applied to the
kernel
weights matrix.bias_regularizer (function) – Regularizer function applied to the bias vector.
activity_regularizer (function) – Regularizer function applied to.
kernel_constraint (function) – Constraint function applied to the
kernel
weights matrix.bias_constraint (function) – Constraint function applied to the bias vector.
- class deepcell.layers.normalization.ImageNormalization3D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Image Normalization layer for 3D data.
- Parameters:
norm_method (str) – Normalization method to use, one of: “std”, “max”, “whole_image”, None.
filter_size (int) – The length of the convolution window.
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.activation (function) – Activation function to use. If you don’t specify anything, no activation is applied (ie. “linear” activation:
a(x) = x
).use_bias (bool) – Whether the layer uses a bias.
kernel_initializer (function) – Initializer for the
kernel
weights matrix, used for the linear transformation of the inputs.bias_initializer (function) – Initializer for the bias vector. If None, the default initializer will be used.
kernel_regularizer (function) – Regularizer function applied to the
kernel
weights matrix.bias_regularizer (function) – Regularizer function applied to the bias vector.
activity_regularizer (function) – Regularizer function applied to.
kernel_constraint (function) – Constraint function applied to the
kernel
weights matrix.bias_constraint (function) – Constraint function applied to the bias vector.
padding
Layers for padding for 2D and 3D images
- class deepcell.layers.padding.ReflectionPadding2D(*args: Any, **kwargs: Any)[source]
Bases:
ZeroPadding2D
Reflection-padding layer for 2D input (e.g. picture).
This layer can add rows and columns of reflected values at the top, bottom, left and right side of an image tensor.
- Parameters:
padding (int, tuple) – If int, the same symmetric padding is applied to height and width. If tuple of 2 ints, interpreted as two different symmetric padding values for height and width:
(symmetric_height_pad, symmetric_width_pad)
. If tuple of 2 tuples of 2 ints, interpreted as((top_pad, bottom_pad), (left_pad, right_pad))
.data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
- class deepcell.layers.padding.ReflectionPadding3D(*args: Any, **kwargs: Any)[source]
Bases:
ZeroPadding3D
Reflection-padding layer for 3D data (spatial or spatio-temporal).
- Parameters:
padding (int, tuple) – The pad-width to add in each dimension. If an int, the same symmetric padding is applied to height and width. If a tuple of 3 ints, interpreted as two different symmetric padding values for height and width:
(symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad)
. If tuple of 3 tuples of 2 ints, interpreted as((left_dim1_pad, right_dim1_pad), (left_dim2_pad, right_dim2_pad), (left_dim3_pad, right_dim3_pad))
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
pooling
Layers to encode location data
- class deepcell.layers.pooling.DilatedMaxPool2D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Dilated max pooling layer for 2D inputs (e.g. images).
- Parameters:
pool_size (int) – An integer or tuple/list of 2 integers: (pool_height, pool_width) specifying the size of the pooling window. Can be a single integer to specify the same value for all spatial dimensions.
strides (int) – An integer or tuple/list of 2 integers, specifying the strides of the pooling operation. Can be a single integer to specify the same value for all spatial dimensions.
dilation_rate (int) – An integer or tuple/list of 2 integers, specifying the dilation rate for the pooling.
padding (str) – The padding method, either
"valid"
or"same"
(case-insensitive).data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
- class deepcell.layers.pooling.DilatedMaxPool3D(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Dilated max pooling layer for 3D inputs.
- Parameters:
pool_size (int) – An integer or tuple/list of 2 integers: (pool_height, pool_width) specifying the size of the pooling window. Can be a single integer to specify the same value for all spatial dimensions.
strides (int) – An integer or tuple/list of 2 integers, specifying the strides of the pooling operation. Can be a single integer to specify the same value for all spatial dimensions.
dilation_rate (int) – An integer or tuple/list of 2 integers, specifying the dilation rate for the pooling.
padding (str) – The padding method, either
"valid"
or"same"
(case-insensitive).data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.
tensor_product
Layers to generate tensor products for 2D and 3D data
- class deepcell.layers.tensor_product.TensorProduct(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Just your regular densely-connected NN layer.
Dense implements the operation:
output = activation(dot(input, kernel) + bias)
where
activation
is the element-wise activation function passed as theactivation
argument,kernel
is a weights matrix created by the layer, andbias
is a bias vector created by the layer (only applicable ifuse_bias
isTrue
).Note: if the input to the layer has a rank greater than 2, then it is flattened prior to the initial dot product with
kernel
.- Parameters:
output_dim (int) – Positive integer, dimensionality of the output space.
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.activation (function) – Activation function to use. If you don’t specify anything, no activation is applied (ie. “linear” activation:
a(x) = x
).use_bias (bool) – Whether the layer uses a bias.
kernel_initializer (function) – Initializer for the
kernel
weights matrix, used for the linear transformation of the inputs.bias_initializer (function) – Initializer for the bias vector. If None, the default initializer will be used.
kernel_regularizer (function) – Regularizer function applied to the
kernel
weights matrix.bias_regularizer (function) – Regularizer function applied to the bias vector.
activity_regularizer (function) – Regularizer function applied to.
kernel_constraint (function) – Constraint function applied to the
kernel
weights matrix.bias_constraint (function) – Constraint function applied to the bias vector.
- Input shape:
nD tensor with shape: (batch_size, …, input_dim). The most common situation would be a 2D input with shape (batch_size, input_dim).
- Output shape:
nD tensor with shape: (batch_size, …, output_dim). For instance, for a 2D input with shape (batch_size, input_dim), the output would have shape (batch_size, output_dim).
upsample
Upsampling layers
- class deepcell.layers.upsample.UpsampleLike(*args: Any, **kwargs: Any)[source]
Bases:
Layer
Layer for upsampling a Tensor to be the same shape as another Tensor.
Adapted from https://github.com/fizyr/keras-retinanet.
- Parameters:
data_format (str) – A string, one of
channels_last
(default) orchannels_first
. The ordering of the dimensions in the inputs.channels_last
corresponds to inputs with shape(batch, height, width, channels)
whilechannels_first
corresponds to inputs with shape(batch, channels, height, width)
.