Skip to main content


Project description

Build Status


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.


$ pip install tfcg


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.Dense(32, name='dense1'))
    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:
        o =, feed_dict={x_p: x})
        _ = tf.identity(o, name="output"), './', 'train.pbtxt')
        parser = tfcg.from_graph_def(sess.graph_def)

read a graph from a file, After dumpping a tensorflow graph file.

import tfcg

parser = tfcg.from_file("./train.pbtxt")


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

tfcg-0.1.4.tar.gz (4.6 kB view hashes)

Uploaded source

Built Distribution

tfcg-0.1.4-py2.py3-none-any.whl (5.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page