DotLayer

DotLayer[]

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

DotLayer[{spec1,spec2,}]

uses given transpose specifications for the respective inputs.

Details and Options

  • DotLayer is typically used inside NetGraph.
  • DotLayer[][{in1,in2,}] explicitly computes the output from applying the layer.
  • The inputs of DotLayer[] should be arrays, and the output is effectively given by Dot[in1,in2,].
  • The output of DotLayer[{spec1,spec2,}][{in1,in2,}] is effectively given by Dot[Transpose[in1,spec1],Transpose[in2,spec2],].
  • The transpose specifications speci can be:
  • Noneno transposition
    m<->ntransposes levels m and n
    {m1<->n1,m2<->n2,}sequentially transposes levels mi and ni
    {n1,n2,}transposes so that the k^(th) level in the input is the nk^(th) level in the output
  • Option InputPorts can be used to specify the number, names or shapes of input ports. If InputPorts is not specified, the number of ports and their shapes are inferred from NetChain or NetGraph connectivity.
  • Besides input ports, DotLayer exposes the following ports for use in NetGraph etc.:
  • "Output"an array
  • 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 shapes of the inputs to DotLayer (after possible transposition) 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.

Examples

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  (6)

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:

Take the dot product of one transposed matrix and another matrix:

Possible Issues  (1)

DotLayer cannot accept symbolic inputs:

Wolfram Research (2017), DotLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/DotLayer.html (updated 2021).

Text

Wolfram Research (2017), DotLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/DotLayer.html (updated 2021).

CMS

Wolfram Language. 2017. "DotLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/DotLayer.html.

APA

Wolfram Language. (2017). DotLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DotLayer.html

BibTeX

@misc{reference.wolfram_2024_dotlayer, author="Wolfram Research", title="{DotLayer}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/DotLayer.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_dotlayer, organization={Wolfram Research}, title={DotLayer}, year={2021}, url={https://reference.wolfram.com/language/ref/DotLayer.html}, note=[Accessed: 03-December-2024 ]}