error
38_ConvTranspose3d_AvgPool_Clamp_Softmax_Multiply.py
started
2026-05-02T23:53:51Z
reference PyTorch source (the prompt the agent sees)
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs average pooling, 3D transposed convolution, clamping,
spatial softmax, and multiplication by a learnable scale.
"""
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, pool_kernel_size, clamp_min, clamp_max):
super(Model, self).__init__()
self.avg_pool = nn.AvgPool3d(pool_kernel_size)
self.conv_transpose = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding)
self.clamp_min = clamp_min
self.clamp_max = clamp_max
self.scale = nn.Parameter(torch.ones(1, out_channels, 1, 1, 1))
def forward(self, x):
"""
Args:
x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).
Returns:
torch.Tensor: Output tensor of shape (batch_size, out_channels, depth, height, width).
"""
x = self.avg_pool(x)
x = self.conv_transpose(x)
x = torch.clamp(x, self.clamp_min, self.clamp_max)
b, c, d, h, w = x.shape
x = x.view(b, c, -1) # flatten spatial dims
x = torch.softmax(x, dim=2)
x = x.view(b, c, d, h, w)
x = x * self.scale
return x
batch_size = 32
in_channels = 32
out_channels = 64
depth, height, width = 32, 64, 64
kernel_size = 3
stride = 2
padding = 1
output_padding = 1
pool_kernel_size = 2
clamp_min = 0.0
clamp_max = 1.0
def get_inputs():
return [torch.rand(batch_size, in_channels, depth, height, width)]
def get_init_inputs():
return [in_channels, out_channels, kernel_size, stride, padding, output_padding, pool_kernel_size, clamp_min, clamp_max]
turn 07200.0s turn · 7200.0s LLM · 0.0s tools
feedbackLLM call failed: Empty: