Skip to content

Instantly share code, notes, and snippets.

@BrianPugh
Created November 19, 2019 23:26
Show Gist options
  • Save BrianPugh/3703f656215cebc5077deb481f1eb250 to your computer and use it in GitHub Desktop.
Save BrianPugh/3703f656215cebc5077deb481f1eb250 to your computer and use it in GitHub Desktop.
tf while loop issues
def while_test(lconfig):
""" Simple tensorflow while_loop test within ADNN
Not to be used as an actual loss
"""
def _cond(i_loop, d):
return tf.less(i_loop, 10)
def _body(i_loop, d):
return i_loop+1, d * 1.2
with tf.control_dependencies([pred_depth]):
_, new_d = tf.while_loop(
_cond, _body,
(0, pred_depth),
back_prop=False,
parallel_iterations=1,
name='while_test',
)
loss = tf.reduce_mean(new_d)
#loss = tf.reduce_mean(pred_depth)
loss = tf.Print(loss, [loss], message='while_test_loss')
return loss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment