I found in many available neural network code implemented using TensorFlow that regularization terms are often implemented by manually adding an additional term to loss valu
cross_entropy = tf.losses.softmax_cross_entropy( logits=logits, onehot_labels=labels) l2_loss = weight_decay * tf.add_n( [tf.nn.l2_loss(tf.cast(v, tf.float32)) for v in tf.trainable_variables()]) loss = cross_entropy + l2_loss