Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph model: cyclic or acyclic #6

Closed
larissa95 opened this issue Oct 16, 2016 · 1 comment
Closed

Graph model: cyclic or acyclic #6

larissa95 opened this issue Oct 16, 2016 · 1 comment

Comments

@larissa95
Copy link
Contributor

larissa95 commented Oct 16, 2016

Hi, I read your book about TensorFlow. In there you wrote that the graph becomes acyclic by unenrolling the loops. Where have you found this information (in code,...)? How do you know how many cycles you have to unroll?

I found ambiguous information about that. For example this one is indicating that the graph might be cyclic:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/common_runtime/simple_placer.cc#L627

@larissa95 larissa95 changed the title Graph model Graph model: cyclic or acyclic Oct 16, 2016
@samjabrahams
Copy link
Owner

Hi @larissa95: This question would be more appropriate for the book's repository, though it is good to note. TensorFlow does support cyclic graphs, through use of specific operations, such as tf.while_loop. In my experience teaching TensorFlow, it's been useful to teach people that the following "cyclic" code doesn't work the way a beginner might think it would:

a = tf.constant(3)
b = tf.mul(a, 2)
a = tf.add(b, 1)  # Does not "loop back" to previous variable `a`

To that end, I found it easy to simply say: "this doesn't work!", instead of getting muddled in the specifics of why one way doesn't work and how another function accomplishes it instead. I should be more careful with the wording, however (saying "TensorFlow does not support cyclic computation" is going to far).

As far as the "unrolling" section is concerned, that section is more about understanding what a cyclic computational graph means when you apply it to something like an RNN: the output from the previous "loop" feeds into the next iteration. It has less to do with TensorFlow-specific functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants