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 a single input port that must be a pair of tensors.
  • 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.
  • The two inputs of DotLayer can be vectors or matrices, and the output is effectively given by Dot[a,b].
  • DotLayer[][{a,b}] explicitly computes the output from applying the layer.
  • DotLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a pair of vectors or matrices
    "Output"a tensor
  • When they cannot be inferred from other layers in a larger net, the option "Input"{shape1,shape2} can be used to fix the dimensions of the two inputs to DotLayer. Each shape can be one of the following:
  • {d} orda vector of dimensions d
    {d1,d2}a matrix of dimensions d1×d2

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 graph 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  (3)

Possible Issues  (2)

See Also

Dot  ThreadingLayer  TotalLayer  SummationLayer  SequenceAttentionLayer  NetChain  NetGraph

Introduced in 2017
(11.1)