Interface FunctionLinear<T extends Tensor>

All Superinterfaces:
Function<T>
All Known Implementing Classes:
FunctionLinear_F32, FunctionLinear_F64

public interface FunctionLinear<T extends Tensor>
extends Function<T>
Applies a linear (or affine) equation to input array. This is a matrix multiplication operation that is performed between the input vector and their respective weights plus bias.
 y = W*x + b
 
where y is the output, W are the weights, x is the input, and b is the bias.
  • Method Details

    • forward

      void forward​(T input, T output)

      Input tensor shape =(N, d[i], ... , d[K])
      where N is the number of stacked inputs, d[i] is the number of inputs along dimension i, and K is the dimension of the input space.

      Tensor Parameters:
      Weight matrix shape=(M,D)
      bias shape=(M)
      where D is the total number of inputs (Product d[i]) and M is the number of outputs.

      NOTE: The tensor parameters' shape has been selected to minimize cache misses during matrix multiplication.

      Specified by:
      forward in interface Function<T extends Tensor>
      Parameters:
      input - Tensor with a shape of (N, d[i], ... , d[k])
      output - Output tensor with shape (N,M). Modified.
    • setParameters

      void setParameters​(List<T> parameters)
      See forward(T, T) for a description of parameters.
      Specified by:
      setParameters in interface Function<T extends Tensor>
      Parameters:
      parameters - Weight and bias tensors with shapes (M, D), and (M,), respectively.
    • getNumberOfOutputs

      int getNumberOfOutputs()
      Returns the number of output elements. This is the variable M.
      Returns:
      Number of output elements.