ThreadingLayer
represents a net layer that takes two input tensors and applies a function f to corresponding tensor elements.
Details and Options

- ThreadingLayer is typically used inside NetGraph.
- ThreadingLayer has an arbitrary number of input ports named 1, 2, etc.
- Within a NetGraph, a ThreadingLayer can be connected using a single edge of the form {src1,src2,…}threadlayer, where threadlayer is the name or index of the ThreadingLayer, or as multiple separate edges given in the corresponding order, as src1threadlayer,src2threadlayer,…,srcnthreadlayer.
- In ThreadingLayer[f], the function f can be any one of the following: Plus, Subtract, Times, Divide, Power, Min, Max, Clip.
- In general, f can be any object that when applied to two arguments gives any combination of Plus, Subtract, etc. together with Ramp, LogisticSigmoid, Tanh, ArcTan, ArcTanh, Sin, Sinh, ArcSin, ArcSinh, Cos, Cosh, ArcCos, ArcCosh, Log, Exp, Sqrt, Abs, Gamma, LogGamma and numbers.
- The function f can also contain expressions of the form "name"[input], where name is one of the named functions ("ELU", "SELU", "SoftSign", etc.) accepted by ElementwiseLayer.
- ThreadingLayer[…][{in1,in2,…}] explicitly computes the output from applying the layer, which is effectively given by f[in1,in2,…].
- ThreadingLayer exposes the following ports for use in NetGraph etc.:
-
1,2,… numeric tensors "Output" a numeric tensor - The option "Inputs"->n can be used to fix the number of inputs to ThreadingLayer.
- When it cannot be inferred from other layers in a larger net, the option "Output"{d1,d2,…} can be used to fix the dimensions of the output of the ThreadingLayer. All inputs will also have their dimensions fixed to the same value.
Examples
open allclose allBasic Examples (3)
Create a ThreadingLayer using Times as the function to be threaded:
Create a ThreadingLayer and apply it to a pair of inputs:
Apply the layer to a pair of inputs:
Create a NetGraph that contains a ThreadingLayer:
Scope (3)
Applications (1)
Possible Issues (3)
See Also
ElementwiseLayer ThreadingLayer NetChain NetGraph NetTrain SoftmaxLayer DropoutLayer
Tutorials
Related Guides
Introduced in 2017
(11.1)
| Updated in 2018 (11.3)