ConstantTimesLayer

ConstantTimesLayer[]

represents a layer that multiplies its input by a learnable scaling tensor.

ConstantTimesLayer[opts]

includes options for initial scaling and other parameters.

Details and Options

  • The scaling tensor learned by ConstantTimesLayer has the same dimensions as the input to ConstantTimesLayer.
  • The input to ConstantTimesLayer is multiplied elementwise by the scaling tensor.
  • The following optional parameters can be included:
  • "Scaling"Automaticinitial scaling tensor
  • When the scale tensor is not explicitly specified or is given as Automatic, it is added automatically when NetInitialize or NetTrain is used. By default, the scale tensor will be initialized to consist of ones.
  • If a scale tensor has been added, ConstantTimesLayer[][input] explicitly computes the output from applying the layer.
  • ConstantTimesLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • The scaling tensor can be obtained from an initialized ConstantTimesLayer using NetExtract[layer,"Scaling"].
  • ConstantTimesLayer is typically used inside NetChain, NetGraph, etc.
  • ConstantTimesLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of arbitrary rank
    "Output"a tensor of arbitrary rank
  • When it cannot be inferred from other layers in a larger net, the option "Input"{d1,d2,,dn} can be used to fix the input of ConstantTimesLayer to be a tensor of dimensions d1×d2××dn.

Examples

open allclose all

Basic Examples  (2)

Create a ConstantTimesLayer:

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

Create a ConstantTimesLayer with an explicit scaling:

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

Apply the layer to an input vector:

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

Scope  (3)

Options  (1)

Properties & Relations  (2)

Possible Issues  (1)

See Also

ConstantArrayLayer  ConstantPlusLayer  ThreadingLayer  NetChain  NetGraph  NetInitialize  NetTrain  NetExtract

Introduced in 2017
(11.1)