GPUCodeForces/S1/uucoco_#35/GrowingCosineUnit_torch.py

26 lines
453 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:
return x * torch.cos(x)
batch_size = 64
feature_dim = 256
def get_inputs():
x = torch.randn(batch_size, feature_dim, dtype=torch.float32)
return [x]
def get_init_inputs():
# GCU 不需要特殊的初始化输入
return []