未验证 提交 b73ffc4c 编写于 作者: L Lv Mengsi 提交者: GitHub

fix elementwise (#4056)

上级 a82f75be
......@@ -12,7 +12,6 @@
- [FAQ](#faq)
- [参考论文](#参考论文)
- [版本更新](#版本更新)
- [作者](#作者)
## 模型简介
......@@ -312,9 +311,5 @@ SPADE整体的网络结构[10]
- 6/2019 新增CGAN, DCGAN, Pix2Pix, CycleGAN,StarGAN, AttGAN, STGAN
## 作者
- [ceci3](https://github.com/ceci3)
- [zhumanyu](https://github.com/zhumanyu)
## 如何贡献代码
如果你可以修复某个issue或者增加一个新功能,欢迎给我们提交PR。如果对应的PR被接受了,我们将根据贡献的质量和难度进行打分(0-5分,越高越好)。如果你累计获得了10分,可以联系我们获得面试机会或者为你写推荐信。
......@@ -62,7 +62,7 @@ class AttGAN_model(object):
"""Concatenate attribute vector on feature map axis."""
ones = fluid.layers.fill_constant_batch_size_like(
z, [-1, a.shape[1], z.shape[2], z.shape[3]], "float32", 1.0)
return fluid.layers.concat([z, ones * a], axis=1)
return fluid.layers.concat([z, fluid.layers.elementwise_mul(ones, a, axis=0)], axis=1)
def Genc(self, input, dim=64, n_layers=5, name='G_enc_', is_test=False):
z = input
......
......@@ -84,7 +84,7 @@ class STGAN_model(object):
"""Concatenate attribute vector on feature map axis."""
ones = fluid.layers.fill_constant_batch_size_like(
z, [-1, a.shape[1], z.shape[2], z.shape[3]], "float32", 1.0)
return fluid.layers.concat([z, ones * a], axis=1)
return fluid.layers.concat([z, fluid.layers.elementwise_mul(ones, a, axis=0)], axis=1)
def Genc(self, input, dim=64, n_layers=5, name='G_enc_', is_test=False):
z = input
......
......@@ -169,7 +169,7 @@ class DTrainer():
shape = [a.shape[0]]
alpha = fluid.layers.uniform_random_batch_size_like(
input=a, shape=shape, min=0.0, max=1.0)
inner = (b - a) * alpha + a
inner = fluid.layers.elementwise_mul((b-a), alpha, axis=0) + a
return inner
x = _interpolate(real, fake)
......
......@@ -177,7 +177,7 @@ class DTrainer():
shape = [a.shape[0]]
alpha = fluid.layers.uniform_random_batch_size_like(
input=a, shape=shape, min=0.0, max=1.0)
inner = (b - a) * alpha + a
inner = fluid.layers.elementwise_mul((b-a), alpha, axis=0) + a
return inner
x = _interpolate(real, fake)
......
......@@ -162,7 +162,7 @@ class DTrainer():
alpha = fluid.layers.uniform_random_batch_size_like(
input=a, shape=shape, min=0.0, max=1.0)
inner = b * (1.0 - alpha) + a * alpha
inner = fluid.layers.elementwise_mul(b, (1.0-alpha), axis=0) + fluid.layers.elementwise_mul(a, alpha, axis=0)
return inner
x = _interpolate(real, fake)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册