(x, *, name, with_conv)
| 13 | |
| 14 | |
| 15 | def upsample(x, *, name, with_conv): |
| 16 | with tf.variable_scope(name): |
| 17 | B, H, W, C = x.shape |
| 18 | x = tf.image.resize(x, size=[H * 2, W * 2], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR, align_corners=True) |
| 19 | assert x.shape == [B, H * 2, W * 2, C] |
| 20 | if with_conv: |
| 21 | x = nn.conv2d(x, name='conv', num_units=C, filter_size=3, stride=1) |
| 22 | assert x.shape == [B, H * 2, W * 2, C] |
| 23 | return x |
| 24 | |
| 25 | |
| 26 | def downsample(x, *, name, with_conv): |