(self, imgs)
| 68 | tf.TensorSpec((None, SHAPE, SHAPE, OUT_CH), tf.float32, 'output')] |
| 69 | |
| 70 | def generator(self, imgs): |
| 71 | # imgs: input: 256x256xch |
| 72 | # U-Net structure, it's slightly different from the original on the location of relu/lrelu |
| 73 | with argscope(BatchNorm, training=True), \ |
| 74 | argscope(Dropout, is_training=True): |
| 75 | # always use local stat for BN, and apply dropout even in testing |
| 76 | with argscope(Conv2D, kernel_size=4, strides=2, activation=BNLReLU): |
| 77 | e1 = Conv2D('conv1', imgs, NF, activation=tf.nn.leaky_relu) |
| 78 | e2 = Conv2D('conv2', e1, NF * 2) |
| 79 | e3 = Conv2D('conv3', e2, NF * 4) |
| 80 | e4 = Conv2D('conv4', e3, NF * 8) |
| 81 | e5 = Conv2D('conv5', e4, NF * 8) |
| 82 | e6 = Conv2D('conv6', e5, NF * 8) |
| 83 | e7 = Conv2D('conv7', e6, NF * 8) |
| 84 | e8 = Conv2D('conv8', e7, NF * 8, activation=BNReLU) # 1x1 |
| 85 | with argscope(Conv2DTranspose, activation=BNReLU, kernel_size=4, strides=2): |
| 86 | return (LinearWrap(e8) |
| 87 | .Conv2DTranspose('deconv1', NF * 8) |
| 88 | .Dropout() |
| 89 | .ConcatWith(e7, 3) |
| 90 | .Conv2DTranspose('deconv2', NF * 8) |
| 91 | .Dropout() |
| 92 | .ConcatWith(e6, 3) |
| 93 | .Conv2DTranspose('deconv3', NF * 8) |
| 94 | .Dropout() |
| 95 | .ConcatWith(e5, 3) |
| 96 | .Conv2DTranspose('deconv4', NF * 8) |
| 97 | .ConcatWith(e4, 3) |
| 98 | .Conv2DTranspose('deconv5', NF * 4) |
| 99 | .ConcatWith(e3, 3) |
| 100 | .Conv2DTranspose('deconv6', NF * 2) |
| 101 | .ConcatWith(e2, 3) |
| 102 | .Conv2DTranspose('deconv7', NF * 1) |
| 103 | .ConcatWith(e1, 3) |
| 104 | .Conv2DTranspose('deconv8', OUT_CH, activation=tf.tanh)()) |
| 105 | |
| 106 | @auto_reuse_variable_scope |
| 107 | def discriminator(self, inputs, outputs): |
no test coverage detected