question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplify TensorGraph API

See original GitHub issue

I’m finding the TensorGraph API kind of cumbersome to work with. This is mainly because you have to call add_layer() for every layer, which forces you to create a variable for every layer. For example, suppose a and b are two layers. As your loss function, you want to multiply them together and take the mean of all elements. (This is a real example I came across. a contains the cost function for every task, and b is the weights.) Currently, you have to write something like this:

graph.add_layer(a)
graph.add_layer(b)
mult = Multiply()
graph.add_layer(mult, parents=[a,b])
reducemean = ReduceMean()
graph.add_layer(reducemean, parents=[mult])
graph.set_loss(reducemean)

I suggest getting rid of add_layer(). You would only need to tell the graph about layers that have special roles, like with set_loss() or add_output(). The parents of each layer would be passed as arguments to its constructor. With this change, the above code could be simplified to

graph.set_loss(ReduceMean(Multiply(a, b)))

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:49 (47 by maintainers)

github_iconTop GitHub Comments

2reactions
lilleswingcommented, May 4, 2017

Can functionality be added to Osprey for https://www.tensorflow.org/api_docs/python/tf/contrib/learn/Evaluable

and

https://www.tensorflow.org/api_docs/python/tf/contrib/learn/Trainable

as these API are in tensorflow contrib they are likely going to become more widespread. They also allow for taking in iterators to deal with larger datasets.

Also making Tensorgraph implement these API would be great.

1reaction
lilleswingcommented, Apr 14, 2017

yeah I’m doing it as part of putting atomic convs in mainline.

https://github.com/lilleswing/deepchem/pull/13

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to graphs and tf.function | TensorFlow Core
Simplify arithmetic operations by eliminating common subexpressions. ... Graph s behind one API (learn more in the Polymorphism section).
Read more >
Model Classes — deepchem 2.6.2.dev documentation
Fits GDBT model with all data. First, this function splits all data into train and valid data (8:2), and finds the best n_estimators....
Read more >
How to use tf.function to speed up Python code in Tensorflow
function API, to give any user the option to convert a regular (eager) python code to a lazy code which is actually speed...
Read more >
Live, Historical and On-demand Market Data Feed and API
dxFeed provides real-time, historical, calculated market data via multiple APIs for stocks, derivatives, commodities, treasuries, indices, forex, ...
Read more >
What does it mean "The tensor's graph is different from the ...
The tf.Session uses the default graph. So in order to use the graph g you would either have to indent the session initialization...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found