【发布时间】:2020-07-10 01:05:43
【问题描述】:
我正在尝试转换一个简单的 GAN 生成器(来自 ClusterGAN):
self.name = 'generator'
self.latent_dim = latent_dim
self.n_c = n_c
self.x_shape = x_shape
self.ishape = (128, 7, 7)
self.iels = int(np.prod(self.ishape))
self.verbose = verbose
self.model = nn.Sequential(
# Fully connected layers
torch.nn.Linear(self.latent_dim + self.n_c, 1024),
nn.BatchNorm1d(1024),
nn.LeakyReLU(0.2, inplace=True),
torch.nn.Linear(1024, self.iels),
nn.BatchNorm1d(self.iels),
nn.LeakyReLU(0.2, inplace=True),
# Reshape to 128 x (7x7)
Reshape(self.ishape),
# Upconvolution layers
nn.ConvTranspose2d(128, 64, 4, stride=2, padding=1, bias=True),
nn.BatchNorm2d(64),
nn.LeakyReLU(0.2, inplace=True),
nn.ConvTranspose2d(64, 1, 4, stride=2, padding=1, bias=True),
nn.Sigmoid()
)
但 onnx-coreml 失败并显示 Error while converting op of type: BatchNormalization. Error message: provided number axes 2 not supported
我以为是 BatchNorm2d,所以我尝试重塑和应用 BatchNorm1d,但我得到了同样的错误。有什么想法吗?我很惊讶我在转换如此简单的模型时遇到问题,所以我假设我一定遗漏了一些明显的东西。
我的目标是 iOS 13 并使用 Opset v10 进行 onnx 转换。
【问题讨论】:
标签: pytorch coreml generative-adversarial-network