Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import tensorflow as tf
- graph = tf.Graph()
- with graph.as_default():
- # in_1 = tf.placeholder(tf.float32, shape=[], name="input_a")
- # in_2 = tf.placeholder(tf.float32, shape=[], name="input_b")
- # const = tf.constant(3, dtype=tf.float32, name="static_value")
- with tf.name_scope("variables"):
- # variable to keep track of how many times the graph has been run
- global_step = tf.Variable(0, dtype=tf.int32, trainable=False, name="global_step")
- # variable that keeps track of the sum of all output values over time
- total_output = tf.Variable(0.0, dtype=tf.float32, trainable=False, name= "total_output")
- with tf.name_scope("transformation"):
- # separate input layer
- with tf.name_scope("input"):
- # create input placeholder - takes in a vector
- a = tf.placeholder(tf.float32, shape=[None], name="input_placeholder_a")
- # separate middle layer
- with tf.name_scope("intermediate_layer"):
- b = tf.reduce_prod(a, name="product_b")
- c = tf.reduce_sum(a, name="sum_c")
- # separate output layer
- with tf.name_scope("output"):
- output = tf.add(b, c, name="output")
- with tf.name_scope("update"):
- # increment the total_output variable by the latest output
- update_total = total_output.assign_add(output)
- # increment the global_step variable, should be run whenever the graph is run
- increment_step = global_step.assign_add(1)
- writer = tf.summary.FileWriter('./name_scope_2', graph=graph)
- writer.close()
Advertisement
Add Comment
Please, Sign In to add comment