oneflow.nn.functional.linear

oneflow.nn.functional.linear(input, weight, bias=None)

Applies a linear transformation to the incoming data: \(y = xA^T + b\).

Shape:

  • Input: \((N, *, in\_features)\) N is the batch size, * means any number of additional dimensions

  • Weight: \((out\_features, in\_features)\)

  • Bias: \((out\_features)\)

  • Output: \((N, *, out\_features)\)

For example:

>>> import numpy as np
>>> import oneflow as flow

>>> input = flow.tensor(np.random.randn(128, 20))
>>> weight = flow.tensor(np.random.randn(30, 20))
>>> output = flow.nn.functional.linear(input, weight)
>>> output.size()
oneflow.Size([128, 30])