GPUCodeForces/S1/gsd123_#61/SquaredReLU_torch.py

25 lines
468 B
Python

import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x: torch.Tensor) -> torch.Tensor:
# SquareReLU = ReLU(x) ^ 2
return F.relu(x).pow(2)
batch_size = 128
feature_dim = 512
def get_inputs():
x = torch.randn(batch_size, feature_dim, dtype=torch.float32)
return [x]
def get_init_inputs():
return []