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
ConvTranspose1d
ConvTranspose1d
class max.nn.ConvTranspose1d(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.
When called, ConvTranspose1d 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 ConvTranspose1d
device = Accelerator() if accelerator_count() > 0 else CPU()
device_ref = DeviceRef.from_device(device)
conv = ConvTranspose1d(
length=3,
in_channels=64,
out_channels=128,
dtype=DType.float32,
stride=1,
padding=0,
output_padding=0,
has_bias=False,
name="conv_transpose1d_weight",
device=device_ref,
)Initializes the ConvTranspose1d layer with weights and optional bias.
-
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 (tuple[int, int]) – Stride of the convolution. Default: 1.
- padding (tuple[int, int, int, int]) – Padding added to input. Default: 0.
- dilation (tuple[int, int]) – Spacing between kernel elements. Default: 1.
- output_padding (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.
bias
The optional bias vector stored on CPU with shape (out_channels,).
Model init moves the bias to device if present.
device
The device where matrix operations are performed.
dilation
Not implemented yet. Assuming dilation = 1 for now.
output_padding
Additional size added to one side of the output shape. Default: 0
padding
Controls the amount of padding applied before and after the input for depth, height, and width dimensions.
permute
permute: bool
bool controls whether self.weight is permuted from PyTorch order to max order. PyTorch order is: (in_channels, out_channels, kernel_length) Max API order: (kernel_length, out_channels, in_channels).
stride
Controls the stride for the cross-correlation.
weight
weight: Weight
The weight matrix stored on CPU with shape (kernel_length, out_channels, in_channels).
Model init moves the weight to device.