Have a question? Connect with the community at the TensorFlow Forum

# tfnlp.layers.DenseEinsum

A densely connected layer that uses tf.einsum as the backing computation.

This layer can perform einsum calculations of arbitrary dimensionality.

`output_shape` Positive integer or tuple, dimensionality of the output space.
`num_summed_dimensions` The number of dimensions to sum over. Standard 2D matmul should use 1, 3D matmul should use 2, and so forth.
`activation` Activation function to use. If you don't specify anything, no activation is applied (ie. "linear" activation: `a(x) = x`).
`use_bias` Boolean, whether the layer uses a bias vector.
`kernel_initializer` Initializer for the `kernel` weights matrix.
`bias_initializer` Initializer for the bias vector.
`kernel_regularizer` Regularizer function applied to the `kernel` weights matrix.
`bias_regularizer` Regularizer function applied to the bias vector.
`activity_regularizer` Regularizer function applied to the output of the layer (its "activation")..
`kernel_constraint` Constraint function applied to the `kernel` weights matrix.
`bias_constraint` Constraint function applied to the bias vector.

#### Input shape:

N-D tensor with shape: `(batch_size, ..., input_dim)`. The most common situation would be a 2D input with shape `(batch_size, input_dim)`.

#### Output shape:

N-D tensor with shape: `(batch_size, ..., units)`. For instance, for a 2D input with shape `(batch_size, input_dim)`, the output would have shape `(batch_size, units)`.

## Methods

### `call`

View source

This is where the layer's logic lives.

Note here that `call()` method in `tf.keras` is little bit different from `keras` API. In `keras` API, you can pass support masking for layers as additional arguments. Whereas `tf.keras` has `compute_mask()` method to support masking.

Args
`inputs` Input tensor, or list/tuple of input tensors.
`*args` Additional positional arguments. Currently unused.
`**kwargs` Additional keyword arguments. Currently unused.

Returns
A tensor or list/tuple of tensors.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]