Created
May 10, 2016 14:06
-
-
Save dalgu90/6b2753a906e653d7d13b205ceb842003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apply proximal gradient for the variables with l1 lasso loss | |
# Non-negative weights constraint | |
if L1_LOSS_WEIGHT > 0: | |
for var in tf.get_collection(utils.LASSO_KEY): | |
th_t = tf.fill(tf.shape(var), tf.convert_to_tensor(L1_LOSS_WEIGHT) * lr) | |
zero_t = tf.zeros(tf.shape(var)) | |
var_temp = var - th_t * tf.sign(var) | |
assign_op = var.assign(tf.select(tf.less(tf.abs(var), th_t), zero_t, var_temp)) | |
l1_op_list.append(assign_op) | |
print('\tL1 loss added: %s(strength: %f)' % (var.name, L1_LOSS_WEIGHT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment