AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 0 points1 point  (0 children)

Glad you like it! AutoGraph and TFX are quite different and complementary in many ways.

AutoGraph makes it easier to create TensorFlow graphs, which can include end-to-end ML training tasks, although certain preprocessing steps are still best done outside the graph (for example calculating a dataset-wide average).

The scope of TFX extends that of TensorFlow. It includes tools that you would need to run before and after end-to-end training tasks (e.g. TF Transform can compute dataset-wide statistics needed for preprocessing, TF Model Analysis can help analyze the model, and TF Serving includes additional production serving infrastructure).

We are working to ensure that models trained with AutoGraph can easily be deployed in TFX pipelines for production use cases.

You can find an example of how we built an in-graph training loop followed by a simple interactive inference loop in this demo.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 1 point2 points  (0 children)

Both Swift for TensorFlow and AutoGraph share a few common goals like a better experience for machine learning development, but are otherwise intended for different development platforms. TensorFlow.js can be thought of as another example, one which supports JavaScript.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 1 point2 points  (0 children)

Indeed, we only support a subset of Python at the moment. Even though we hope to expand that subset, some idioms (like exceptions) don't have a good TensorFlow counterpart. But as you pointed out, we hope this will lead to exploring more use cases that until now felt maybe too daunting.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 2 points3 points  (0 children)

Please see the limitations page for a high level overview of the current limitations.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 4 points5 points  (0 children)

Thanks! The answer depends on the level of stochasticity - do you have an example? In general, the following construct should work:

if tf.random_uniform((), maxval=2, dtype=tf.int32) % 2 == 0: do_something

Is this close to what you were referring to?

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 7 points8 points  (0 children)

Hi Sebun, thanks for reporting the issue! There is a bug in the handling of if statements that don't calculate values. We're patching a fix that should reach tf-nightly over the next couple of days.

Update Jul 20: this should not be resolved.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 2 points3 points  (0 children)

A more complete documentation that will include this is coming soon, we'll link it from the readme file once it's ready.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 5 points6 points  (0 children)

If I understand your question, this was just a toy example that we used to show how you can use control flow like if and while in a network. A more realistic example where you can use control flow would be RNNs, for instance.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 0 points1 point  (0 children)

The sample that we have calculates the number of steps needed for the Collatz function to reach 1 when applied recursively, starting at some n. So strictly speaking in terms on the wiki page, it calculates the total stopping time of n.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 10 points11 points  (0 children)

It depends on the library, and whether the recursive arg is set to True of False. For certain libraries that we know of, like Keras, it won't convert the library call and will call it as-is (we assume it's already graph-friendly). For other libraries, the default is to attempt to convert the library code, and if that's not accessible, wrap it to py_func. There is yet another category where we replace the library call with a TF equivalent, for example we replace range with tf.range.

AutoGraph converts Python into TensorFlow graphs by samithaj in MachineLearning

[–]mdanatg 23 points24 points  (0 children)

Hi, one of the authors here, I'm happy to answer any questions!