def l1_regularizer(weight=1.0, scope=None):
 def regularizer(tensor):
  with tf.name_scope(scope, 'L1Regularizer', [tensor]):
   l1_weight = tf.convert_to_tensor(weight, dtype=tensor.dtype.base_dtype, name='weight')
   return tf.multiply(l1_weight, tf.reduce_sum(tf.abs(tensor)), name='value')
 return regularizer

def l1_regularizer ( weight = 1.0 , scope = None ) : def regularizer ( tensor ) : with tf . name_scope ( scope , 'L1Regularizer' , [ tensor ] ) : l1_weight = tf . convert_to_tensor ( weight , dtype = tensor . dtype . base_dtype , name = 'weight' ) return tf . multiply ( l1_weight , tf . reduce_sum ( tf . abs ( tensor ) ) , name = 'value' ) return regularizer
define a l1 regularizer .