在使用AdaptiveInstanceNorm时遇到RuntimeError: weight should contain 8192 elements not 512问题

问题来源:

想要利用FUNIT模型,由于原模型开源的代码支持单张class_image,再修改模型支持多张class_image输入后出现了:untimeError: weight should contain 8192 elements not 512问题

问题出现后我立马定位到错误处,错误指出是在AdaptiveInstanceNorm的使用F.batch_norm时的权重shape与所需要的不一致。

因此,我立马找到encode_classLabel后的结果,发现在求多个classLabel的encode结果的均值时,将得到的Tensor的batch转为了1,这个是不行的,

错误的代码:
torch.mean(class_codes[i], dim=0).unsqueeze(0)

解决方法:

循环遍历所有的encode_classLabel结果,求和取batch上的均值。

你可能感兴趣的:(深度学习,pytorch,人工智能)