That is just a norm and might not necessarily be the 1-norm. Nevertheless, in tensorflow that is pretty straightforward if you have your parameters stored in a list (I will call it para_list):
l1_reg_term = sum([tf.reduce_sum(tf.abs(_var)) for _var in para_list])
reg_loss = loss + alpha * l1_reg_term
One way to get your parameters is to name them. Then you can just extract them from the global space with tf.get_global_variables() or tf.get_trainable_variables().
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.