def dna_transformation(prev_image, dna_input):
 prev_image_pad = tf.pad(prev_image, [[0, 0], [2, 2], [2, 2], [0, 0]])
 image_height = int(prev_image.get_shape()[1])
 image_width = int(prev_image.get_shape()[2])
 inputs = []
 for xkern in range(DNA_KERN_SIZE):
  for ykern in range(DNA_KERN_SIZE):
   inputs.append(tf.expand_dims(tf.slice(prev_image_pad, [0, xkern, ykern, 0], [(-1), image_height, image_width, (-1)]), [3]))
 inputs = tf.concat(3, inputs)
 kernel = (tf.nn.relu((dna_input - RELU_SHIFT)) + RELU_SHIFT)
 kernel = tf.expand_dims((kernel / tf.reduce_sum(kernel, [3], keep_dims=True)), [4])
 return tf.reduce_sum((kernel * inputs), [3], keep_dims=False)

def dna_transformation ( prev_image , dna_input ) : prev_image_pad = tf . pad ( prev_image , [ [ 0 , 0 ] , [ 2 , 2 ] , [ 2 , 2 ] , [ 0 , 0 ] ] ) image_height = int ( prev_image . get_shape ( ) [ 1 ] ) image_width = int ( prev_image . get_shape ( ) [ 2 ] ) inputs = [ ] for xkern in range ( DNA_KERN_SIZE ) : for ykern in range ( DNA_KERN_SIZE ) : inputs . append ( tf . expand_dims ( tf . slice ( prev_image_pad , [ 0 , xkern , ykern , 0 ] , [ ( - 1 ) , image_height , image_width , ( - 1 ) ] ) , [ 3 ] ) ) inputs = tf . concat ( 3 , inputs ) kernel = ( tf . nn . relu ( ( dna_input - RELU_SHIFT ) ) + RELU_SHIFT ) kernel = tf . expand_dims ( ( kernel / tf . reduce_sum ( kernel , [ 3 ] , keep_dims = True ) ) , [ 4 ] ) return tf . reduce_sum ( ( kernel * inputs ) , [ 3 ] , keep_dims = False )
apply dynamic neural advection to previous image .