def l2_loss(tensor, weight=1.0, scope=None):
 with tf.name_scope(scope, 'L2Loss', [tensor]):
  weight = tf.convert_to_tensor(weight, dtype=tensor.dtype.base_dtype, name='loss_weight')
  loss = tf.multiply(weight, tf.nn.l2_loss(tensor), name='value')
  tf.add_to_collection(LOSSES_COLLECTION, loss)
  return loss

def l2_loss ( tensor , weight = 1.0 , scope = None ) : with tf . name_scope ( scope , 'L2Loss' , [ tensor ] ) : weight = tf . convert_to_tensor ( weight , dtype = tensor . dtype . base_dtype , name = 'loss_weight' ) loss = tf . multiply ( weight , tf . nn . l2_loss ( tensor ) , name = 'value' ) tf . add_to_collection ( LOSSES_COLLECTION , loss ) return loss
define a l2loss .