def relaxed_average(var_name_suffix, rx_step):
 relaxed_vars = []
 for l in xrange(rx_step):
  with tf.variable_scope(('RX%d' % l), reuse=True):
   try:
    relaxed_vars.append(tf.get_variable(var_name_suffix))
   except ValueError:
    pass
 dsum = tf.add_n(relaxed_vars)
 avg = (dsum / len(relaxed_vars))
 diff = [(v - avg) for v in relaxed_vars]
 davg = tf.add_n([(d * d) for d in diff])
 return (avg, tf.reduce_sum(davg))

def relaxed_average ( var_name_suffix , rx_step ) : relaxed_vars = [ ] for l in xrange ( rx_step ) : with tf . variable_scope ( ( 'RX%d' % l ) , reuse = True ) : try : relaxed_vars . append ( tf . get_variable ( var_name_suffix ) ) except ValueError : pass dsum = tf . add_n ( relaxed_vars ) avg = ( dsum / len ( relaxed_vars ) ) diff = [ ( v - avg ) for v in relaxed_vars ] davg = tf . add_n ( [ ( d * d ) for d in diff ] ) return ( avg , tf . reduce_sum ( davg ) )
calculate the average of relaxed variables having var_name_suffix .