represents a layer that adds a learnable bias to its input.


includes options for initial bias and other parameters.

Details and Options

  • The bias tensor learned by ConstantPlusLayer has the same dimensions as the input to ConstantPlusLayer.
  • The input to ConstantPlusLayer is added elementwise to the bias tensor.
  • The following optional parameters can be included:
  • "Biases"Automaticinitial bias tensor
  • When the bias is not explicitly specified or is given as Automatic, it is added automatically when NetInitialize or NetTrain is used. By default, the bias will be initialized to a zero tensor.
  • If a bias has been added, ConstantPlusLayer[][input] explicitly computes the output from applying the layer.
  • ConstantPlusLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • The bias tensor can be obtained from an initialized ConstantPlusLayer using NetExtract[layer,"Biases"].
  • ConstantPlusLayer is typically used inside NetChain, NetGraph, etc.
  • ConstantPlusLayer 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 ConstantPlusLayer to be a tensor of dimensions d1×d2××dn.


open allclose all

Basic Examples  (2)

Create a ConstantPlusLayer:

Click for copyable input

Create an initialized ConstantPlusLayer whose input is a vector of length 3:

Click for copyable input

Apply the layer to an input vector:

Click for copyable input

Scope  (3)

Options  (1)

Properties & Relations  (4)

Possible Issues  (1)

See Also

ConstantArrayLayer  ConstantTimesLayer  LinearLayer  TotalLayer  ElementwiseLayer  NetChain  NetGraph  NetInitialize  NetTrain  NetExtract


Introduced in 2017