Class Linear

java.lang.Object
ai.beestream.jitnn.nn.Module
ai.beestream.jitnn.nn.Linear
All Implemented Interfaces:
AutoCloseable

public final class Linear extends Module
y = x W^T + b with W of shape [out, in]. Initialised like PyTorch's nn.Linear: weight and bias uniform in [-1/sqrt(in), 1/sqrt(in)).
  • Constructor Details

    • Linear

      public Linear(int in, int out, long seed)
      A linear layer from in to out features with a bias, initialised from seed.
    • Linear

      public Linear(int in, int out, boolean bias, long seed)
      A linear layer from in to out features, with or without a bias, initialised from seed.
  • Method Details

    • weight

      public Tensor weight()
      The weight [out, in].
    • bias

      public Tensor bias()
      The bias [out], or null without one.
    • forward

      public Tensor forward(Tensor x)
      Description copied from class: Module
      Applies the module to x.
      Specified by:
      forward in class Module
    • forwardRelu

      public Tensor forwardRelu(Tensor x)
      relu(forward(x)) as one fused GEMM; Sequential uses it for a Linear followed by ReLU.