Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created September 30, 2017 00:23
Show Gist options
  • Save wchargin/b01873ec552a7d0f0a1882e10ed5cdd9 to your computer and use it in GitHub Desktop.
Save wchargin/b01873ec552a7d0f0a1882e10ed5cdd9 to your computer and use it in GitHub Desktop.
exploratory attempt at converting a TensorFlow graph to gv (manually)
digraph images_demo_gaussian_blur {
rankdir = "BT";
labelloc = "b";
fontname = "Roboto";
node [fontname = "Roboto"];
edge [fontname = "Roboto"];
gr_decode [label="decode_image", shape=box, style=rounded];
gr_image [label="image", shape=box, style=rounded];
gr_decode -> gr_image [label="480×640×3"];
// I'm not going to put all the other edge shape-labels in...
op_cast [label="Cast"];
gr_image -> op_cast;
subgraph {
rank = "same";
op_truediv [label="truediv"];
miniop_y [shape=point, xlabel="y"];
miniop_y -> op_truediv;
}
op_cast -> op_truediv;
op_placeholder [label="Placeholder"];
gr_filter [label="filter", shape=box, style=rounded];
op_placeholder -> gr_filter;
subgraph cluster_convolve {
label = "convolve";
bgcolor = "#bbc6dd";
op_stack [label="stack"];
// in-edge from truediv, which is outside of group
op_conv2d [label="Conv2D"];
op_stack -> op_conv2d
subgraph {
rank="same";
op_expanddims [label="ExpandDims"];
// in-edge from filter, which is outside of group
miniop_dim [shape=point, xlabel="dim"];
miniop_dim -> op_expanddims;
}
subgraph {
rank = "same";
op_expanddims_1 [label="ExpandDims_1"];
miniop_dim_1 [shape=point, xlabel="dim"];
miniop_dim_1 -> op_expanddims_1;
}
op_expanddims -> op_expanddims_1;
subgraph {
rank = "same";
op_expanddims_2 [label="ExpandDims_2"];
miniop_dim_2 [shape=point, xlabel="dim"];
miniop_dim_2 -> op_expanddims_2;
}
subgraph {
rank = "same";
op_expanddims_3 [label="ExpandDims_3"];
miniop_dim_3 [shape=point, xlabel="dim"];
miniop_dim_3 -> op_expanddims_3;
}
op_expanddims_2 -> op_expanddims_3;
gr_eye [
label="eye",
shape=box,
style="rounded,filled",
fillcolor="#bddbdb",
];
gr_eye -> op_expanddims_2;
op_mul [label="mul"];
op_expanddims_1 -> op_mul;
op_expanddims_3 -> op_mul;
op_mul -> op_conv2d;
gr_assert_type [
label="assert_type",
shape=box,
style="rounded,filled",
fillcolor="#c5e2b6",
];
subgraph {
rank = "same";
op_strided_slice [label="strided_slice"];
miniop_stack_1 [shape=point, xlabel="stack_1"];
miniop_stack_2 [shape=point, xlabel="stack_1"];
miniop_stack_3 [shape=point, xlabel="stack_2"];
{miniop_stack_1, miniop_stack_2, miniop_stack_3} -> op_strided_slice;
}
op_conv2d -> op_strided_slice;
}
gr_filter -> op_expanddims;
op_truediv -> op_stack;
gr_convolve_1 [
label="convolve_1",
shape=box,
style="rounded,filled",
fillcolor = "#bbc6dd",
];
gr_convolve_2 [
label="convolve_2",
shape=box,
style="rounded,filled",
fillcolor = "#bbc6dd",
];
gr_convolve_3 [
label="convolve_3",
shape=box,
style="rounded,filled",
fillcolor = "#bbc6dd",
];
op_strided_slice -> gr_convolve_1 -> gr_convolve_2 -> gr_convolve_3;
gr_filter -> {gr_convolve_1, gr_convolve_2, gr_convolve_3};
gr_convert_to_uint8 [label="convert_to_uint8", shape=box, style=rounded];
{
op_truediv,
op_strided_slice,
gr_convolve_1,
gr_convolve_2,
gr_convolve_3
} -> gr_convert_to_uint8;
gr_box_to_gaussian [label="box_to_gaussian", shape=box, style=rounded];
gr_convert_to_uint8 -> gr_box_to_gaussian;
}
@wchargin
Copy link
Author

output of dot -Tpng -O images_demo.dot:
GraphViz output

TensorBoard graph, from "Download PNG":
TensorBoard output

@wchargin
Copy link
Author

wchargin commented Oct 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment