Surgery of TensorFlow (v1.10) graphs

Stories from a PhD in Computational Chemistry

This short post shows how to replace some operations in a TensorFlow graph that has been reloaded from a .pb file. This is actually quite simple to do, but all the tutorials that I found when I needed to do this were for older versions of TensorFlow, so it took me way longer than it should have.

First of all, let’s create a toy graph and save it to a file.

This graph includes a matrix of shape (2, 4) which gets multiplied by another matrix of shape (4, 3), so that the resulting matrix has shape (2, 3). This is then added to another matrix of shape (2, 3) to give the final result.

Then, the graph is saved  and one has to specify what are the input and output tensors of the graph. In this case they are a and out.

Now, we want to reload the…

View original post 121 more words

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s