Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions GraphvizbasedVisualition.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "27dedb17",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Generated by graphviz version 3.0.0 (20220226.1711)\n",
" -->\n",
"<!-- Title: round&#45;table Pages: 1 -->\n",
"<svg width=\"8pt\" height=\"8pt\"\n",
" viewBox=\"0.00 0.00 8.00 8.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 4)\">\n",
"<title>round&#45;table</title>\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-4 4,-4 4,4 -4,4\"/>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.graphs.Digraph at 0x7fdb41736cd0>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import graphviz # doctest: +NO_EXE\n",
"#dot = graphviz.Digraph(comment='The Round Table')\n",
"dot = graphviz.Digraph('round-table', comment='The Round Table') \n",
"dot #doctest: +ELLIPSIS"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "44a6c0c1",
"metadata": {},
"outputs": [],
"source": [
"dot.node('A', 'DFF') # doctest: +NO_EXE\n",
"dot.node('B', 'AND')\n",
"dot.node('L', 'NOT')\n",
"\n",
"dot.edges(['AB', 'BL'])\n",
"dot.edge('A', 'L', constraint='false')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "64ff1f86",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"// The Round Table\n",
"digraph \"round-table\" {\n",
"\tA [label=DFF]\n",
"\tB [label=AND]\n",
"\tL [label=NOT]\n",
"\tA -> B\n",
"\tB -> L\n",
"\tA -> L [constraint=false]\n",
"}\n",
"\n"
]
}
],
"source": [
"print(dot.source)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "eac01595",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Generated by graphviz version 3.0.0 (20220226.1711)\n",
" -->\n",
"<!-- Title: round&#45;table Pages: 1 -->\n",
"<svg width=\"81pt\" height=\"188pt\"\n",
" viewBox=\"0.00 0.00 80.64 188.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 184)\">\n",
"<title>round&#45;table</title>\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-184 76.64,-184 76.64,4 -4,4\"/>\n",
"<!-- A -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>A</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"29.9\" cy=\"-162\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"29.9\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\">DFF</text>\n",
"</g>\n",
"<!-- B -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>B</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"29.9\" cy=\"-90\" rx=\"29.8\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"29.9\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\">AND</text>\n",
"</g>\n",
"<!-- A&#45;&gt;B -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>A&#45;&gt;B</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M29.9,-143.7C29.9,-135.98 29.9,-126.71 29.9,-118.11\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"33.4,-118.1 29.9,-108.1 26.4,-118.1 33.4,-118.1\"/>\n",
"</g>\n",
"<!-- L -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>L</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"29.9\" cy=\"-18\" rx=\"28.7\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"29.9\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">NOT</text>\n",
"</g>\n",
"<!-- A&#45;&gt;L -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>A&#45;&gt;L</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M44.38,-146.71C53.35,-136.8 64.05,-122.76 68.9,-108 73.89,-92.8 73.89,-87.2 68.9,-72 65.28,-60.98 58.39,-50.36 51.4,-41.56\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"53.91,-39.1 44.77,-33.73 48.56,-43.62 53.91,-39.1\"/>\n",
"</g>\n",
"<!-- B&#45;&gt;L -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>B&#45;&gt;L</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M29.9,-71.7C29.9,-63.98 29.9,-54.71 29.9,-46.11\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"33.4,-46.1 29.9,-36.1 26.4,-46.1 33.4,-46.1\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.graphs.Digraph at 0x7fdb41736cd0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dot"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b7d9505d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
110 changes: 110 additions & 0 deletions TensorflowbasedGraph.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "119c1861",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /Users/rmkchowdary/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/compat/v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"non-resource variables are not supported in the long term\n"
]
}
],
"source": [
"import tensorflow.compat.v1 as tf\n",
"tf.disable_v2_behavior()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "aa16b6fe",
"metadata": {},
"outputs": [],
"source": [
"a = tf.placeholder(tf.bool,name =\"a\")\n",
"b = tf.placeholder(tf.bool,name =\"b\")\n",
"y = tf.math.logical_and(a,b,name=\"AND\")\n",
"y= tf.math.logical_not(a,name=\"NOT\")\n",
"z= tf.math.logical_and(y,y,name=\"y\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a9b4d555",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-03-23 18:26:51.940414: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
]
}
],
"source": [
"\n",
"from tensorflow.python.summary.writer.writer import FileWriter\n",
"sess1 = tf.compat.v1.Session()\n",
"#writer=tf.summary.FileWriter('./my_graph',sess.graph)\n",
"writer = tf.summary.FileWriter(\"log_dir1/logic_and\", sess1.graph) "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5a22ca48",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"UsageError: Line magic function `%tensorboard` not found.\n"
]
}
],
"source": [
"#run in terminal below command\n",
"#tensorboard --logdir=/log_dir1/logic_and"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b38b9e60",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}