GPUCodeForces/S1/uucoco_#115/ValueLoss_torch.py

24 lines
456 B
Python

import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
def forward(self, values: torch.Tensor, returns: torch.Tensor) -> torch.Tensor:
loss = ((values - returns) ** 2).mean()
return loss
batch_size = 32
def get_inputs():
values = torch.randn(batch_size)
returns = torch.randn(batch_size)
return [values, returns]
def get_init_inputs():
return []