def _downscale(images, K):
 arr = np.zeros([K, K, 3, 3])
 arr[:, :, 0, 0] = (1.0 / (K * K))
 arr[:, :, 1, 1] = (1.0 / (K * K))
 arr[:, :, 2, 2] = (1.0 / (K * K))
 dowscale_weight = tf.constant(arr, dtype=tf.float32)
 downscaled = tf.nn.conv2d(images, dowscale_weight, strides=[1, K, K, 1], padding='SAME')
 return downscaled

def _downscale ( images , K ) : arr = np . zeros ( [ K , K , 3 , 3 ] ) arr [ : , : , 0 , 0 ] = ( 1.0 / ( K * K ) ) arr [ : , : , 1 , 1 ] = ( 1.0 / ( K * K ) ) arr [ : , : , 2 , 2 ] = ( 1.0 / ( K * K ) ) dowscale_weight = tf . constant ( arr , dtype = tf . float32 ) downscaled = tf . nn . conv2d ( images , dowscale_weight , strides = [ 1 , K , K , 1 ] , padding = 'SAME' ) return downscaled
differentiable image downscaling by a factor of k .