forked from ccf-ai-infra/GPUCodeForces
27 lines
535 B
Python
27 lines
535 B
Python
import torch
|
|
import torch.nn as nn
|
|
|
|
|
|
class Model(nn.Module):
|
|
def __init__(self, mu=0.0, beta=1.0):
|
|
super().__init__()
|
|
self.mu = mu
|
|
self.beta = beta
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
diff = x - self.mu
|
|
|
|
return torch.rsqrt(diff.pow(2) + self.beta * self.beta)
|
|
|
|
|
|
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 [0.0, 1.0] |