Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No graph is built for visualization #88

Open
leom97 opened this issue Jul 17, 2022 · 2 comments
Open

No graph is built for visualization #88

leom97 opened this issue Jul 17, 2022 · 2 comments

Comments

@leom97
Copy link

leom97 commented Jul 17, 2022

To debug my dolfin-adjoint code I want to visualize the compute graph.

I receive this error after calling tape.visualize():

File "/home/anaconda3/envs/masters_thesis/lib/python3.10/site-packages/tensorflow/python/ops/script_ops.py", line 632, in py_func_common
    result = func(*[np.array(x) for x in inp])
TypeError: Tape._tf_add_blocks.<locals>.<lambda>() takes 0 positional arguments but 2 were given

This is fixed by the following:

    try:
      result = func(*[np.array(x) for x in inp])
    except:
      result = None

inspired from the following lines of tape.py, where one sees that a lambda with zero args is eventually called with more than zero inputs:

tf.py_func(lambda: None, in_tensors, [tf.float64],
                                            name=self._valid_tf_scope_name(str(block)))

Anyhow, tensorboard now says empty graph, so that nothing is visualized. How can this be solved?

@dham
Copy link
Member

dham commented Jul 17, 2022

I'm not familiar with the tensorflow-based visualisation so I'll leave the direct part to others. However, if you are using pyadjoint master then direct PDF visualisation is also supported and could be a workaround. If you pass a filename ending in .pdf then you get a PDF visualisation. E.g. tape.visualise("tape.pdf"). This requires the python package networkx and the system package graphviz (e.g. sudo apt install graphviz).

@leom97 leom97 changed the title No graph is build for visualization No graph is built for visualization Jul 23, 2022
@leom97
Copy link
Author

leom97 commented Jul 23, 2022

@dham This does indeed work, although the resulting pdf visualization if quite hard to read, without the possibility to expand and collapse blocks. Thank you for the answer in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants