DotLayer

DotLayer[]

represents a net layer that takes the dot product of two tensors.

Details and Options

  • DotLayer is typically used inside NetGraph.
  • DotLayer has an arbitrary number of input ports named 1, 2, etc.
  • Within a NetGraph, a DotLayer can be connected using a single edge of the form {src1,src2,}dotlayer, where dotlayer is the name or index of the DotLayer, or as multiple separate edges given in the corresponding order, as src1dotlayer,src2dotlayer,,srcndotlayer.
  • The inputs of DotLayer should be numeric tensors, and the output is effectively given by Dot[in1,in2,].
  • DotLayer[][{in1,in2,}] explicitly computes the output from applying the layer.
  • DotLayer exposes the following ports for use in NetGraph etc.:
  • 1,2,numeric tensors
    "Output"a numeric tensor
  • The option "Inputs"->n can be used to fix the number of inputs to DotLayer.
  • When they cannot be inferred from other layers in a larger net, the option "Inputs"{shape1,shape2,} can be used to fix the dimensions of inputs to DotLayer. Each shape can be one of the following:
  • {d} orda vector of dimensions d
    {d1,d2,}a tensor of dimensions d1×d2
  • The shapes of the inputs to DotLayer should be such that the last dimension of inputi is equal to the first dimension of inputi+1.

Examples

open allclose all

Basic Examples  (3)

Create a DotLayer:

In[1]:=
Click for copyable input
Out[1]=

Create a DotLayer:

In[1]:=
Click for copyable input
Out[1]=

Apply the layer to two input vectors to produce a scalar:

In[2]:=
Click for copyable input
Out[2]=

Create a NetGraph that contains a DotLayer:

In[1]:=
Click for copyable input
Out[1]=

Apply the graph to an input:

In[2]:=
Click for copyable input
Out[2]=

Scope  (5)

Possible Issues  (1)

See Also

Dot  ThreadingLayer  TotalLayer  SummationLayer  SequenceAttentionLayer  NetChain  NetGraph

Tutorials

Introduced in 2017
(11.1)
| Updated in 2018
(11.3)