Normalize.__init__() missing 1 required positional argument: 'std'
时间: 2023-09-22 12:09:50 浏览: 303
normalize.css-8.0.1.zip
引用[1]:出现错误:Traceback (most recent call last): File "D:\ProgramFiles\Pytorch-Basic-GANs-master\Pytorch-Basic-GANs-master\vanilla_gan.py", line 95, in <module> convert_model(single_model="model.pth") TypeError: convert_model() missing 1 required positional argument: 'para_model'。[1]这个错误是因为在调用convert_model函数时,缺少了一个必需的参数para_model。引用[2]:出现这种错误,就是class中init函数中的参数没有赋值。[2]在这个例子中,ff类的初始化函数__init__缺少了一个参数n的赋值,导致在创建实例a时出现错误。正确的做法是在创建实例a时传入参数,例如a = ff(1)。引用[3]:ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([192, 1])) is deprecated.添加:validity = validity.squeeze(-1) ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([192])) is deprecated.实验之后发现batch_size与input size成3倍关系,尝试除3:z = torch.randn([batch_size/3, z_dim]).to(device) 错误:TypeError: randn(): argument 'size' (position 1) must be tuple of ints, not list。[3]这个错误是因为torch.randn函数的参数size需要传入一个元组(tuple),而不是一个列表(list)。正确的做法是将参数size改为一个元组,例如z = torch.randn((batch_size/3, z_dim)).to(device)。问题:Normalize.__init__() missing 1 required positional argument: 'std'。
阅读全文