Simple-Calculation-Graph
Sat 17 May 2025
title: "Template" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false
import tensorflow as tf
import os
# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# a = (b + c) * (c + 2)
const = tf.constant(2.0, name='const')
# create variables
b = tf.Variable(2.0, name='b')
c = tf.Variable(1.0, name='c')
# Fill the operations
d = tf.add(b, c, name='d')
e = tf.add(c, const, name='e')
a = tf.multiply(d, e, name='a')
# Variable initialization
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
a_out = sess.run(a)
print(a_out)
9.0
b = tf.placeholder(tf.float32, [None, 1], name='b')
import numpy as np
with tf.Session() as sess:
sess.run(init_op)
b_out = sess.run(a, feed_dict={b: np.arange(0, 10)[:, np.newaxis]})
print(b_out)
9.0
Score: 10
Category: tensorflow-work