Session-And-With-Block

Sat 17 May 2025

title: "Session and With Block" 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 = tf.Variable(2)
b = a * 4
b
<tf.Tensor 'mul:0' shape=() dtype=int32>
init_op = tf.initialize_all_variables()
with tf.Session() as session:
    session.run(init_op)
    result = session.run(a + b)
    print(result)
10


Score: 5

Category: tensorflow-work