beyondml.tflow.layers package
Submodules
beyondml.tflow.layers.FilterLayer module
- class beyondml.tflow.layers.FilterLayer.FilterLayer(*args, **kwargs)[source]
Bases:
Layer
Layer which filters inputs based on status of on or off
Example:
>>> # Create a model with just a FilterLayer >>> input_layer = tf.keras.layers.Input(10) >>> filter_layer = mann.layers.FilterLayer()(input_layer) >>> model = tf.keras.models.Model(input_layer, filter_layer) >>> model.compile() >>> # Call the model with the layer turned on >>> data = np.arange(10).reshape((1, 10)) >>> model.predict(data) array([[0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]], dtype=float32) >>> # Turn off the FilterLayer and call it again >>> model.layers[-1].turn_off() >>> # Model must be recompiled after turning the layer on or off >>> model.compile() >>> model.predict(data) array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MaskedConv2D module
- class beyondml.tflow.layers.MaskedConv2D.MaskedConv2D(*args, **kwargs)[source]
Bases:
Layer
Masked 2-dimensional convolutional layer. For full documentation of the convolutional architecture, see the TensorFlow Keras Convolutional2D layer documentation.
This layer implements masking consistent with the BeyondML API to support developing sparse models.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MaskedConv3D module
- class beyondml.tflow.layers.MaskedConv3D.MaskedConv3D(*args, **kwargs)[source]
Bases:
Layer
Masked 3-dimensional convolutional layer. For full documentation of the convolutional architecture, see the TensorFlow Keras Convolutional3D layer documentation.
This layer implements masking consistent with the BeyondML API to support developing sparse models
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MaskedDense module
- class beyondml.tflow.layers.MaskedDense.MaskedDense(*args, **kwargs)[source]
Bases:
Layer
Masked fully connected layer. For full documentation of the fully-connected architecture, see the TensorFlow Keras Dense layer documentation.
This layer implements masking consistent with the BeyondML API to support developing sparse models.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MultiConv2D module
- class beyondml.tflow.layers.MultiConv2D.MultiConv2D(*args, **kwargs)[source]
Bases:
Layer
Multitask 2-dimensional convolutional layer
This layer implements multiple stacks of convolutional weights to account for different ways individual neurons activate for various tasks. It is expected that to train using the RSN2 algorithm that MultiMaskedConv2D layers be used during training and then those layers be converted to this layer type.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MultiConv3D module
- class beyondml.tflow.layers.MultiConv3D.MultiConv3D(*args, **kwargs)[source]
Bases:
Layer
Multitask 3-dimensional convolutional layer
This layer implements multiple stacks of convolutional weights to account for different ways individual neurons activate for various tasks. It is expected that to train using the RSN2 algorithm that MultiMaskedConv3D layers be used during training and then those layers be converted to this layer type.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MultiDense module
- class beyondml.tflow.layers.MultiDense.MultiDense(*args, **kwargs)[source]
Bases:
Layer
Multitask fully connected layer
This layer implements multiple stacks of fully connected weights to account for different ways neurons can activate for various tasks. It is expected that to train using the RSN2 algorithm that MultiMaskedDense layers be used during training and then those layers be converted to this layer type.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MultiMaskedConv2D module
- class beyondml.tflow.layers.MultiMaskedConv2D.MultiMaskedConv2D(*args, **kwargs)[source]
Bases:
Layer
Masked multitask 2-dimensional convolutional layer. This layer implements multiple stacks of the convolutional architecture and implements masking consistent with the BeyondML API to support developing sparse multitask models.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MultiMaskedConv3D module
- class beyondml.tflow.layers.MultiMaskedConv3D.MultiMaskedConv3D(*args, **kwargs)[source]
Bases:
Layer
Masked multitask 3-dimensional convoluational layer. This layer implements multiple stacks of the convolutional architecture and implements masking consistent with the BeyondML API to support developing sparse multitask models.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property kernel_size
beyondml.tflow.layers.MultiMaskedDense module
- class beyondml.tflow.layers.MultiMaskedDense.MultiMaskedDense(*args, **kwargs)[source]
Bases:
Layer
Masked multitask fully connected layer. This layer implements multiple stacks of the fully-connected architecture and implements masking with the BeyondML API to support developing sparse multitask models.
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MultiMaxPool2D module
- class beyondml.tflow.layers.MultiMaxPool2D.MultiMaxPool2D(*args, **kwargs)[source]
Bases:
Layer
Multitask Max Pooling Layer. This layer implements the Max Pooling algorithm across multiple inputs for developing multitask models
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MultiMaxPool3D module
- class beyondml.tflow.layers.MultiMaxPool3D.MultiMaxPool3D(*args, **kwargs)[source]
Bases:
Layer
Multitask 3D Max Pooling Layer. This layer implements the Max Pooling algorithm across multiple inputs for developing multitask models
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.MultitaskNormalization module
- class beyondml.tflow.layers.MultitaskNormalization.MultitaskNormalization(*args, **kwargs)[source]
Bases:
Layer
Multitask layer which normalizes all inputs to sum to 1
- build(input_shape)[source]
Creates the variables of the layer (for subclass implementers).
This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call. It is invoked automatically before the first execution of call().
This is typically used to create the weights of Layer subclasses (at the discretion of the subclass implementer).
- Parameters:
input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SelectorLayer module
- class beyondml.tflow.layers.SelectorLayer.SelectorLayer(*args, **kwargs)[source]
Bases:
Layer
Layer which selects individual inputs
Example:
>>> # Create a model with two inputs and one SelectorLayer >>> input_1 = tf.keras.layers.Input(10) >>> input_2 = tf.keras.layers.Input(10) >>> selector = mann.layers.SelectorLayer(1)([input_1, input_2]) # 1 here indicates to select the second input and return it >>> model = tf.keras.models.Model([input_1, input_2], selector) >>> model.compile() >>> # Call the model >>> data1 = np.arange(10).reshape((1, 10)) >>> data2 = 2*np.arange(10).reshape((1, 10)) >>> model.predict([data1, data2]) array([[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.]], dtype=float32)
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
- property sel_index
beyondml.tflow.layers.SparseConv2D module
- class beyondml.tflow.layers.SparseConv2D.SparseConv2D(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the Convolutional layer. If used in a model, must be saved and loaded via pickle
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SparseConv3D module
- class beyondml.tflow.layers.SparseConv3D.SparseConv3D(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the Convolutional layer. If used in a model, must be saved and loaded via pickle
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SparseDense module
- class beyondml.tflow.layers.SparseDense.SparseDense(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the Dense layer. If used in a model, must be saved and loaded via pickle
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SparseMultiConv2D module
- class beyondml.tflow.layers.SparseMultiConv2D.SparseMultiConv2D(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the MultiConv layer. If used in a model, must be saved and loaded via pickle
- build(input_shapes)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SparseMultiConv3D module
- class beyondml.tflow.layers.SparseMultiConv3D.SparseMultiConv3D(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the MultiConv layer. If used in a model, must be saved and loaded via pickle
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SparseMultiDense module
- class beyondml.tflow.layers.SparseMultiDense.SparseMultiDense(*args, **kwargs)[source]
Bases:
Layer
Sparse implementation of the MultiDense layer. If used in a model, must be saved and loaded via pickle
- build(input_shape)[source]
Build the layer in preparation to be trained or called. Should not be called directly, but rather is called when the layer is added to a model
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
beyondml.tflow.layers.SumLayer module
- class beyondml.tflow.layers.SumLayer.SumLayer(*args, **kwargs)[source]
Bases:
Layer
Layer which adds all inputs together. All inputs must have compatible shapes
Example:
>>> # Create a model with just a SumLayer and two inputs >>> input_1 = tf.keras.layers.Input(10) >>> input_2 = tf.keras.layers.Input(10) >>> sum_layer = mann.layers.SumLayer()([input_1, input_2]) >>> model = tf.keras.models.Model([input_1, input_2], sum_layer) >>> model.compile() >>> # Call the model >>> data = np.arange(10).reshape((1, 10)) >>> model.predict([data, data]) array([[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.]], dtype=float32)
- call(inputs)[source]
This is where the layer’s logic lives and is called upon inputs
- Parameters:
inputs (TensorFlow Tensor or Tensor-like) – The inputs to the layer
- Returns:
outputs – The outputs of the layer’s logic
- Return type:
TensorFlow Tensor
- classmethod from_config(config)[source]
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()[source]
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
Module contents
Custom layers to use when building MANN models