<jupyter_start><jupyter_text>visualize the graph  Graphviz<jupyter_code>import tensorflow as tf
from graphviz import Digraph
from IPython.display import clear_output, Image, display, HTML
def tf_to_dot(graph):
    """
    visualize graph with graphviz
    """
    dot = Digraph()
    # initialize node
    for n in g.as_graph_def().node:
        dot.node(n.name, label=n.name)
        
        # initialize edge
        for i in n.input:
            dot.edge(i, n.name) 
    return dot
g = tf.Graph()

with g.as_default():
    X = tf.placeholder(tf.float32, name="X")
    
    with tf.name_scope("Layer1"):
        W1 = tf.placeholder(tf.float32, name="W1")
        b1 = tf.placeholder(tf.float32, name="b1")

        a1 = tf.nn.relu(tf.matmul(X, W1) + b1)
    
    with tf.name_scope("Layer2"):
        W2 = tf.placeholder(tf.float32, name="W2")
        b2 = tf.placeholder(tf.float32, name="b2")

        a2 = tf.nn.relu(tf.matmul(a1, W2) + b2)

    with tf.name_scope("Layer3"):
        W3 = tf.placeholder(tf.float32, name="W3")
        b3 = tf.placeholder(tf.float32, name="b3")

        y_hat = tf.matmul(a2, W3) + b3
    
tf.summary.FileWriter("logs", g).close()
tf_to_dot(g)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14356435643564355, 'fraction_numerical': 0.03217821782178218, 'mean_word_length': 2.675757575757576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '597345', 'license': 'MIT', 'n_tokens_mistral': 472, 'n_tokens_neox': 460, 'n_words': 90, 'path': 'P2-Traffic-Sign-Classifier/test/visualization_graviz.ipynb', 'repo_name': 'YouYueHuang/SelfDrivingCarProjects', 'size': '1212'}