For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python class
WeightNormConvTranspose1d
WeightNormConvTranspose1dβ
class max.nn.WeightNormConvTranspose1d(length, in_channels, out_channels, dtype, stride=1, padding=0, dilation=1, output_padding=0, device=None, has_bias=False, permute=False, name=None)
Bases: Module
A 1D transposed convolution operator over an input image composed of several input planes.
MAX implements weight normalization as described in Weight
Normalization. Weight normalization
reparameterizes weights in terms of a direction vector v and a
magnitude scalar g. This can help improve optimization by decoupling
the length and direction of weight vectors.
When called, WeightNormConvTranspose1d accepts a
TensorValue of shape (batch, length, in_channels)
and returns a TensorValue of shape (batch, new_length, out_channels). If permute=True, the input and output
follow PyTorch channel-first layout: (batch, in_channels, length) and
(batch, out_channels, new_length).
from max.driver import Accelerator, CPU, accelerator_count
from max.dtype import DType
from max.graph import DeviceRef
from max.nn import WeightNormConvTranspose1d
device = Accelerator() if accelerator_count() > 0 else CPU()
device_ref = DeviceRef.from_device(device)
conv = WeightNormConvTranspose1d(
length=3,
in_channels=64,
out_channels=128,
dtype=DType.float32,
stride=1,
padding=0,
output_padding=0,
has_bias=False,
device=device_ref,
)Initializes the WeightNormConvTranspose1d layer.
-
Parameters:
-
- length (int) β The length of the convolution kernel.
- in_channels (int) β Number of channels in the input image.
- out_channels (int) β Number of channels produced by the convolution.
- dtype (DType) β The data type for weights and bias.
- stride (int | tuple[int, int]) β Stride of the convolution. Default: 1.
- padding (int | tuple[int, int, int, int]) β Padding added to input. Default: 0.
- dilation (int | tuple[int, int]) β Spacing between kernel elements. Default: 1.
- output_padding (int | tuple[int, int]) β Additional size added to output shape. Default: 0.
- device (DeviceRef | None) β The target device for computation.
- has_bias (bool) β When True, adds a bias vector. Default: False.
- permute (bool) β Whether to permute weights between PyTorch and MAX format.
- name (str | None) β Base name for weights.
convβ
conv: ConvTranspose1d
The underlying ConvTranspose1d layer.
deviceβ
The device where matrix operations are performed.
weight_gβ
weight_g: Weight
The magnitude parameter g for weight normalization.
weight_vβ
weight_v: Weight
The direction parameter v for weight normalization.