deepctr.layers.interaction module

Authors:
Weichen Shen,wcshen1994@163.com, Harshit Pande
class deepctr.layers.interaction.AFMLayer(attention_factor=4, l2_reg_w=0, dropout_rate=0, seed=1024, **kwargs)[source]

Attentonal Factorization Machine models pairwise (order-2) feature interactions without linear term and bias.

Input shape
  • A list of 3D tensor with shape: (batch_size,1,embedding_size).
Output shape
  • 2D tensor with shape: (batch_size, 1).
Arguments
  • attention_factor : Positive integer, dimensionality of the
attention network output space.
  • l2_reg_w : float between 0 and 1. L2 regularizer strength
applied to attention network.
  • dropout_rate : float between in [0,1). Fraction of the attention net output units to dropout.
  • seed : A Python integer to use as random seed.
References
  • [Attentional Factorization Machines : Learning the Weight of Feature

Interactions via Attention Networks](https://arxiv.org/pdf/1708.04617.pdf)

build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, training=None, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.BiInteractionPooling(**kwargs)[source]

Bi-Interaction Layer used in Neural FM,compress the pairwise element-wise product of features into one single vector.

Input shape
  • A 3D tensor with shape:(batch_size,field_size,embedding_size).
Output shape
  • 3D tensor with shape: (batch_size,1,embedding_size).
References
  • [He X, Chua T S. Neural factorization machines for sparse predictive analytics[C]//Proceedings of the 40th International ACM SIGIR conference on Research and Development in Information Retrieval. ACM, 2017: 355-364.](http://arxiv.org/abs/1708.05027)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
class deepctr.layers.interaction.BilinearInteraction(bilinear_type='interaction', seed=1024, **kwargs)[source]

BilinearInteraction Layer used in FiBiNET.

Input shape
  • A list of 3D tensor with shape: (batch_size,1,embedding_size).
Output shape
  • 3D tensor with shape: (batch_size,1,embedding_size).
Arguments
  • str : String, types of bilinear functions used in this layer.
  • seed : A Python integer to use as random seed.
References
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.CIN(layer_size=(128, 128), activation='relu', split_half=True, l2_reg=1e-05, seed=1024, **kwargs)[source]

Compressed Interaction Network used in xDeepFM.This implemention is adapted from code that the author of the paper published on https://github.com/Leavingseason/xDeepFM.

Input shape
  • 3D tensor with shape: (batch_size,field_size,embedding_size).
Output shape
  • 2D tensor with shape: (batch_size, featuremap_num) featuremap_num =  sum(self.layer_size[:-1]) // 2 + self.layer_size[-1] if split_half=True,else sum(layer_size) .
Arguments
  • layer_size : list of int.Feature maps in each layer.
  • activation : activation function used on feature maps.
  • split_half : bool.if set to False, half of the feature maps in each hidden will connect to output unit.
  • seed : A Python integer to use as random seed.
References
  • [Lian J, Zhou X, Zhang F, et al. xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems[J]. arXiv preprint arXiv:1803.05170, 2018.] (https://arxiv.org/pdf/1803.05170.pdf)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.CrossNet(layer_num=2, l2_reg=0, seed=1024, **kwargs)[source]

The Cross Network part of Deep&Cross Network model, which leans both low and high degree cross feature.

Input shape
  • 2D tensor with shape: (batch_size, units).
Output shape
  • 2D tensor with shape: (batch_size, units).
Arguments
  • layer_num: Positive integer, the cross layer number
  • l2_reg: float between 0 and 1. L2 regularizer strength applied to the kernel weights matrix
  • seed: A Python integer to use as random seed.
References
  • [Wang R, Fu B, Fu G, et al. Deep & cross network for ad click predictions[C]//Proceedings of the ADKDD‘17. ACM, 2017: 12.](https://arxiv.org/abs/1708.05123)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.FGCNNLayer(filters=(14, 16), kernel_width=(7, 7), new_maps=(3, 3), pooling_width=(2, 2), **kwargs)[source]

Feature Generation Layer used in FGCNN,including Convolution,MaxPooling and Recombination.

Input shape
  • A 3D tensor with shape:(batch_size,field_size,embedding_size).
Output shape
  • 3D tensor with shape: (batch_size,new_feture_num,embedding_size).
References
  • [Liu B, Tang R, Chen Y, et al. Feature Generation by Convolutional Neural Network for Click-Through Rate Prediction[J]. arXiv preprint arXiv:1904.04447, 2019.](https://arxiv.org/pdf/1904.04447)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.FM(**kwargs)[source]

Factorization Machine models pairwise (order-2) feature interactions without linear term and bias.

Input shape
  • 3D tensor with shape: (batch_size,field_size,embedding_size).
Output shape
  • 2D tensor with shape: (batch_size, 1).
References
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
class deepctr.layers.interaction.FieldWiseBiInteraction(use_bias=True, seed=1024, **kwargs)[source]

Field-Wise Bi-Interaction Layer used in FLEN,compress the pairwise element-wise product of features into one single vector.

Input shape
  • A list of 3D tensor with shape:(batch_size,field_size,embedding_size).
Output shape
  • 2D tensor with shape: (batch_size,embedding_size).
Arguments
  • use_bias : Boolean, if use bias.
  • seed : A Python integer to use as random seed.
References
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.FwFMLayer(num_fields=4, regularizer=1e-06, **kwargs)[source]

Field-weighted Factorization Machines

Input shape
  • 3D tensor with shape: (batch_size,field_size,embedding_size).
Output shape
  • 2D tensor with shape: (batch_size, 1).
Arguments
  • num_fields : integer for number of fields
  • regularizer : L2 regularizer weight for the field strength parameters of FwFM
References
  • [Field-weighted Factorization Machines for Click-Through Rate Prediction in Display Advertising]

https://arxiv.org/pdf/1806.03514.pdf

build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.InnerProductLayer(reduce_sum=True, **kwargs)[source]

InnerProduct Layer used in PNN that compute the element-wise product or inner product between feature vectors.

Input shape
  • a list of 3D tensor with shape: (batch_size,1,embedding_size).
Output shape
  • 3D tensor with shape: (batch_size, N*(N-1)/2 ,1) if use reduce_sum. or 3D tensor with shape: (batch_size, N*(N-1)/2, embedding_size ) if not use reduce_sum.
Arguments
  • reduce_sum: bool. Whether return inner product or element-wise product
References
  • [Qu Y, Cai H, Ren K, et al. Product-based neural networks for user response prediction[C]//Data Mining (ICDM), 2016 IEEE 16th International Conference on. IEEE, 2016: 1149-1154.](https://arxiv.org/pdf/1611.00144.pdf)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.InteractingLayer(att_embedding_size=8, head_num=2, use_res=True, seed=1024, **kwargs)[source]

A Layer used in AutoInt that model the correlations between different feature fields by multi-head self-attention mechanism.

Input shape
  • A 3D tensor with shape: (batch_size,field_size,embedding_size).
Output shape
  • 3D tensor with shape:(batch_size,field_size,att_embedding_size * head_num).
Arguments
  • att_embedding_size: int.The embedding size in multi-head self-attention network.
  • head_num: int.The head number in multi-head self-attention network.
  • use_res: bool.Whether or not use standard residual connections before output.
  • seed: A Python integer to use as random seed.
References
  • [Song W, Shi C, Xiao Z, et al. AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks[J]. arXiv preprint arXiv:1810.11921, 2018.](https://arxiv.org/abs/1810.11921)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.OutterProductLayer(kernel_type='mat', seed=1024, **kwargs)[source]

OutterProduct Layer used in PNN.This implemention is adapted from code that the author of the paper published on https://github.com/Atomu2014/product-nets.

Input shape
  • A list of N 3D tensor with shape: (batch_size,1,embedding_size).
Output shape
  • 2D tensor with shape:(batch_size,N*(N-1)/2 ).
Arguments
  • kernel_type: str. The kernel weight matrix type to use,can be mat,vec or num
  • seed: A Python integer to use as random seed.
References
  • [Qu Y, Cai H, Ren K, et al. Product-based neural networks for user response prediction[C]//Data Mining (ICDM), 2016 IEEE 16th International Conference on. IEEE, 2016: 1149-1154.](https://arxiv.org/pdf/1611.00144.pdf)
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
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.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.
class deepctr.layers.interaction.SENETLayer(reduction_ratio=3, seed=1024, **kwargs)[source]

SENETLayer used in FiBiNET.

Input shape
  • A list of 3D tensor with shape: (batch_size,1,embedding_size).
Output shape
  • A list of 3D tensor with shape: (batch_size,1,embedding_size).
Arguments
  • reduction_ratio : Positive integer, dimensionality of the
attention network output space.
  • seed : A Python integer to use as random seed.
References
build(input_shape)[source]

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Arguments:
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, training=None, **kwargs)[source]

This is where the layer’s logic lives.

Arguments:
inputs: Input tensor, or list/tuple of input tensors. **kwargs: Additional keyword arguments.
Returns:
A tensor or list/tuple of tensors.
compute_mask(inputs, mask=None)[source]

Computes an output mask tensor.

Arguments:
inputs: Tensor or list of tensors. mask: Tensor or list of tensors.
Returns:
None or a tensor (or list of tensors,
one per output tensor of the layer).
compute_output_shape(input_shape)[source]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Arguments:
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.
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).

Returns:
Python dictionary.