GPUCodeForces/S1/uucoco_#43/RadialBasisFunction_torch.py

25 lines
477 B
Python

import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, beta=1.0, mu=0.0):
super().__init__()
self.beta = beta
self.mu = mu
def forward(self, x: torch.Tensor) -> torch.Tensor:
return torch.exp(-self.beta * (x - self.mu).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 [1.0, 0.0]