-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Tensorboard graphs are really useful to check defined ops and the general net structure. However, this is hard to do when variables are reused, because the graph is complicated by many edges that simply propagate shared variables. For example, the graph associated to:
import tensorflow as tf
# Meaningless model
input_A = tf.keras.Input(shape=(1,2), name='Input_A')
input_B = tf.keras.Input(shape=(1,2), name='Input_B')
inner_block = tf.keras.Sequential(
[ tf.keras.layers.Dense(1) for i in range(50) ])
output = inner_block(input_A) + inner_block(input_B)
model = tf.keras.Model((input_A,input_B), output)
# Write
tf.keras.callbacks.TensorBoard('.', write_graph=True).set_model(model)is

The 100 tensors in this graph are simply inputs of ReadVariableOps. In more complex graphs, these connections become the thicker arrows, completely changing the logic structure of the net. In

the three generators are the same layer, called three times with different inputs. Here, the real inputs have been even pushed out of the main graph (they come from the ImagePreprocessing layer), because of the stronger connections for variables.
I think that how variables are propagated is mostly a tensorflow internal concern. Even though the graph is logically correct (because actual variable resources are in the first block), I'd like the possibility to hide inputs of ReadVariableOps (and, why not, even control dependencies).
Details: Tensorflow 2.1.0-rc0 built from source.
Related thread tensorflow/tensorflow#9545