represents a net layer that takes two input arrays and applies a function f to corresponding array elements.

Details and Options


open allclose all

Basic Examples  (2)

Create a ThreadingLayer using Times as the function to be threaded:

Apply the layer to a pair of inputs:

Create a NetGraph that contains a ThreadingLayer:

Apply the layer to two vectors:

Scope  (3)

Create a ThreadingLayer that takes a specific number of inputs:

Create a ThreadingLayer that takes two matrices as input, and apply it to data:

Create a ThreadingLayer that uses a custom transformation to compute a spherical Gaussian:

Evaluate the layer on two input vectors to get a vector of outputs:

Plot the output of the layer:

Applications  (1)

Define a hinge loss using a ThreadingLayer:

Create a net that computes the hinge loss with a margin of 2:

When the target is within distance 2 of the input, the loss is zero:

The loss increases linearly beyond a distance of 2:

Plot the loss as a function of input for a fixed target of 2:

Perform linear regression using the hinge loss:

Plot the solution:

Compare the solutions obtained using the hinge loss, mean absolute and mean squared error:

Possible Issues  (3)

ThreadingLayer cannot accept symbolic inputs:

Certain choices of f can produce failures for inputs outside their domain:

Some custom transformations are not supported:

Introduced in 2017
Updated in 2018