speechbrain.nnet.linear moduleο
Library implementing linear transformation.
- Authors
Mirco Ravanelli 2020
Davide Borra 2021
Summaryο
Classes:
Computes a linear transformation y = wx + b. |
Referenceο
- class speechbrain.nnet.linear.Linear(n_neurons, input_shape=None, input_size=None, bias=True, max_norm=None, combine_dims=False)[source]ο
Bases:
ModuleComputes a linear transformation y = wx + b.
- Parameters:
n_neurons (int) β It is the number of output neurons (i.e, the dimensionality of the output).
input_shape (tuple) β It is the shape of the input tensor.
input_size (int) β Size of the input tensor.
bias (bool) β If True, the additive bias b is adopted.
max_norm (float) β weight max-norm.
combine_dims (bool) β If True and the input is 4D, combine 3rd and 4th dimensions of input.
Example
>>> inputs = torch.rand(10, 50, 40) >>> lin_t = Linear(input_shape=(10, 50, 40), n_neurons=100) >>> output = lin_t(inputs) >>> output.shape torch.Size([10, 50, 100])
- forward(x)[source]ο
Returns the linear transformation of input tensor.
- Parameters:
x (torch.Tensor) β Input to transform linearly.
- Returns:
wx β The linearly transformed outputs.
- Return type: