tf_conceptual_graph
Project description
tf_conceptual_graph
Create tensorflow(1.x) conceptual graph. Conceputual graph is not aimed to reconstruct a neural network. The main purpose of this conceputual graph is for treating a neural network as a heterogeneous graph. Once we can treat neural networks as heterogeneous graphs, we can apply graph neural network methods for them to predict inference results from trained neural networks. From the view point, we can optimize neural network structures.
Installtion
$ pip install tfcg
Usage
read a graph_def object from object api(sess.graph_def)
import numpy as np
import tensorflow as tf
import tfcg
with tf.Graph().as_default() as graph:
model = tf.keras.Sequential()
x = np.random.rand(128, 28, 28, 3)
model.add(tf.keras.layers.Conv2D(16, 3, input_shape=[28, 28, 3], name='conv1'))
model.add(tf.keras.layers.Conv2D(32, 1, name='conv2'))
model.add(tf.keras.layers.Conv2D(64, 2, name='conv3'))
model.add(tf.keras.layers.Conv2D(128, 2, name='conv4'))
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(32, name='dense1'))
model.add(tf.keras.layers.ReLU())
model.add(tf.keras.layers.Dense(16, name='dense2'))
x_p = tf.placeholder(tf.float32, [None, 28, 28, 3], name='input')
out_p = model(x_p)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
o = sess.run(out_p, feed_dict={x_p: x})
_ = tf.identity(o, name="output")
tf.io.write_graph(sess.graph, './', 'train.pbtxt')
parser = tfcg.from_graph_def(sess.graph_def)
parser.dump_json("conceptual_graph.json")
parser.dump_img("output.png")
read a graph from a file, After dumpping a tensorflow graph file.
import tfcg
parser = tfcg.from_file("./train.pbtxt")
parser.dump_json("conceptual_graph.json")
mparser.dump_img("output.png")
Examples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tfcg-0.1.4.tar.gz.
File metadata
- Download URL: tfcg-0.1.4.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e477996074b3bc509651eb0d98a37b82846eca016887c4012fa71fb6242c3c3
|
|
| MD5 |
ef6ae1a3c7313f120e195861aad79f03
|
|
| BLAKE2b-256 |
ac7d17ae7771d1b0b626bc7507794b7b9258d6c12330513e2edecffa0f808ebf
|
File details
Details for the file tfcg-0.1.4-py2.py3-none-any.whl.
File metadata
- Download URL: tfcg-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00209ee871219c5fb4e9386fa8286e0fe1d07fb312a39cb7594183f3f8025528
|
|
| MD5 |
60d350a8255c24cb989a1a654ee20e47
|
|
| BLAKE2b-256 |
3b9cbeff8051b75e86ffe1474b2f5f5cd3ebd8fdaca9099f77ec1a01d4de798a
|