(inputs, channel=32, num_blocks=4, name='generator', reuse=False)
| 60 | |
| 61 | |
| 62 | def unet_generator(inputs, channel=32, num_blocks=4, name='generator', reuse=False): |
| 63 | with tf.variable_scope(name, reuse=reuse): |
| 64 | |
| 65 | x0 = slim.convolution2d(inputs, channel, [7, 7], activation_fn=None) |
| 66 | x0 = tf.nn.leaky_relu(x0) |
| 67 | |
| 68 | x1 = slim.convolution2d(x0, channel, [3, 3], stride=2, activation_fn=None) |
| 69 | x1 = tf.nn.leaky_relu(x1) |
| 70 | x1 = slim.convolution2d(x1, channel*2, [3, 3], activation_fn=None) |
| 71 | x1 = tf.nn.leaky_relu(x1) |
| 72 | |
| 73 | x2 = slim.convolution2d(x1, channel*2, [3, 3], stride=2, activation_fn=None) |
| 74 | x2 = tf.nn.leaky_relu(x2) |
| 75 | x2 = slim.convolution2d(x2, channel*4, [3, 3], activation_fn=None) |
| 76 | x2 = tf.nn.leaky_relu(x2) |
| 77 | |
| 78 | for idx in range(num_blocks): |
| 79 | x2 = resblock(x2, out_channel=channel*4, name='block_{}'.format(idx)) |
| 80 | |
| 81 | x2 = slim.convolution2d(x2, channel*2, [3, 3], activation_fn=None) |
| 82 | x2 = tf.nn.leaky_relu(x2) |
| 83 | |
| 84 | h1, w1 = tf.shape(x2)[1], tf.shape(x2)[2] |
| 85 | x3 = tf.image.resize_bilinear(x2, (h1*2, w1*2)) |
| 86 | x3 = slim.convolution2d(x3+x1, channel*2, [3, 3], activation_fn=None) |
| 87 | x3 = tf.nn.leaky_relu(x3) |
| 88 | x3 = slim.convolution2d(x3, channel, [3, 3], activation_fn=None) |
| 89 | x3 = tf.nn.leaky_relu(x3) |
| 90 | |
| 91 | h2, w2 = tf.shape(x3)[1], tf.shape(x3)[2] |
| 92 | x4 = tf.image.resize_bilinear(x3, (h2*2, w2*2)) |
| 93 | x4 = slim.convolution2d(x4+x0, channel, [3, 3], activation_fn=None) |
| 94 | x4 = tf.nn.leaky_relu(x4) |
| 95 | x4 = slim.convolution2d(x4, 3, [7, 7], activation_fn=None) |
| 96 | #x4 = tf.clip_by_value(x4, -1, 1) |
| 97 | return x4 |
| 98 | |
| 99 | |
| 100 |
nothing calls this directly
no test coverage detected