tensorflow / tensorflow/tensorboard

Reused variables create huge graphs

Open
#3,118 2 comments 0 reactions 1 assignee View on GitHub

@psybuzz is already working on this.

Since Jan 8, 2020.

core:frontend plugin:graph stat:awaiting tensorflower
Dominant language
TypeScript
Stars
7.2k
Forks
1.7k
Avg merge
4d 22h
Merged PRs (30d)
1

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 https://github.com/tensorflow/tensorflow/issues/9545

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.