That only sets the graph-level random seed. If you execute this snippet several times in a row, the graph will change, and two shuffle statements will get different operation-level seeds. The details are described in the doc string for set_random_seed
To get deterministic a_shuf you can either
- Call
tf.reset_default_graph() between invocations or
- Set operation-level seed for shuffle:
a_shuf = tf.random_shuffle(a, seed=42)