With PyTorch program (see below) I got a solving error: AssertionError: Трансформация…
- User
With PyTorch program (see below) I got a solving error: AssertionError: Трансформация ToDtypeV1(dtype=torch.float64, scale=True) должна выполнять нормализацию данных к диапазону [0; 1].
import torch import torch.nn as nn import torchvision.transforms as tfs
import torchvision.transforms.v2 as tfs_v2 - недоступен на Stepik
здесь объявляйте класс ToDtypeV1
class ToDtypeV1(nn.Module): def init(self, dtype: torch.dtype, scale: bool = False): super().init() self.dtype = dtype self.scale = scale
def forward(self, item: torch.Tensor): item = item.to(dtype=self.dtype) if self.scale and self.dtype in (torch.float16, torch.float32, torch.float64): item_min = item.min() item_max = item.max() item = (item - item_min) / item_max return itemH, W = 128, 128 img_orig = torch.randint(0, 256, size=(3, H, W), dtype=torch.uint8) # тензор в программе не менять
средние для каждого цветового канала (первая ось)
img_mean = torch.mean(img_orig.float(), [1, 2])
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.