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


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.


open allclose all

Basic Examples  (2)

Create a ConstantTimesLayer:

Click for copyable input

Create a ConstantTimesLayer with an explicit scaling:

Click for copyable input

Apply the layer to an input vector:

Click for copyable input

Scope  (3)

Options  (1)

Properties & Relations  (2)

Possible Issues  (1)

See Also

ConstantArrayLayer  ConstantPlusLayer  ThreadingLayer  NetChain  NetGraph  NetInitialize  NetTrain  NetExtract


Introduced in 2017