represents a net layer that takes the dot product of two or more arrays.

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 arrays, and the output is effectively given by Dot[in1,in2,].
  • DotLayer[][{in1,in2,}] explicitly computes the output from applying the layer.
  • When given a NumericArray as input, the output will be a NumericArray.
  • DotLayer exposes the following ports for use in NetGraph etc.:
  • 1,2,arrays
    "Output"an array
  • 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,}an array 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.
  • Options[DotLayer] gives the list of default options to construct the layer. Options[DotLayer[]] gives the list of default options to evaluate the layer on some data.
  • Information[DotLayer[]] gives a report about the layer.
  • Information[DotLayer[],prop] gives the value of the property prop of DotLayer[]. Possible properties are the same as for NetGraph.


open allclose all

Basic Examples  (2)

Create a DotLayer:

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

Create a NetGraph that contains a DotLayer:

Apply the graph to an input:

Scope  (5)

Create a DotLayer that accepts specific sizes of input:

Take the dot product of two length-3 vectors:

Take the dot product of a 2×3 matrix and a length-3 vector:

Take the dot product of two 2×2 matrices:

Take the dot product of three 2×2 matrices:

Possible Issues  (1)

DotLayer cannot accept symbolic inputs:

Introduced in 2017
Updated in 2018