import numpy as np
import tensorflow as tf
class simpleTest(tf.test.TestCase):
def setUp(self):
self.X = np.random.random_sample(size = (2, 3, 2))
def test(self):
a = 4
x = tf.constant(self.X, dtype=tf.float32)
if a % 2 == 0:
y = 2*x
else:
y = 3*x
z = 4*y
with self.test_session():
print y.eval()
print z.eval()
if __name__ == "__main__":
tf.test.main()
Here y is tensorflow variable and is defined inside the if else block, why does it can be used outside the block?