#自定义层 #不带参数的层 class CenterLayer(nn.Module): def __init__(self,**kwargs): super().__init__(**kwargs) def forward(self,X): return X-X.mean() layer=CenterLayer() print(layer(torch.tensor([1.0,2,3,4,5]))) #RuntimeError: mean(): could not infer output dtype. Input dtype must be either a floating point or complex dtype. Got: Long #将输入数据类型从[1,2,3,,4,5]改为[1.0,2,3,4,5]
5.4自定义层(错误:RuntimeError: mean(): could not infer output dtype. Input dtype must be either a floatin)
最新推荐文章于 2024-07-12 19:06:42 发布