(x, *, name, with_conv)
| 24 | |
| 25 | |
| 26 | def downsample(x, *, name, with_conv): |
| 27 | with tf.variable_scope(name): |
| 28 | B, H, W, C = x.shape |
| 29 | if with_conv: |
| 30 | x = nn.conv2d(x, name='conv', num_units=C, filter_size=3, stride=2) |
| 31 | else: |
| 32 | x = tf.nn.avg_pool(x, 2, 2, 'SAME') |
| 33 | assert x.shape == [B, H // 2, W // 2, C] |
| 34 | return x |
| 35 | |
| 36 | |
| 37 | def resnet_block(x, *, temb, name, out_ch=None, conv_shortcut=False, dropout): |