Skip to content Skip to sidebar Skip to footer

Valueerror: Operation 'cond_25/shape' Has Been Marked As Not Fetchable

The above error occurs when I try to do the following: se = tf.Session() cont = tf.constant([[1., 2., 4., 5.], [5., 2., 7., 8.]]) def f1(): print(se.run(tf.shape(cont))) re

Solution 1:

The error you see is explained here

Please note this line in the explanation.

Recall that all functions passed to tf.cond() or tf.while_loop() must be pure functions, and so they must not modify their environment.

import tensorflow as tf


se = tf.Session()
cont = tf.constant([[1., 2., 4., 5.], [5., 2., 7., 8.]])
deff1():
    print('Shape is ',tf.shape(cont))
    returnTruedeff2():
    returnFalse
r = tf.cond(tf.greater(tf.constant(10), tf.constant(9)), f1, f2)

This code executes without error.

If you are confused with static and dynamic shapes this explains it well.

Post a Comment for "Valueerror: Operation 'cond_25/shape' Has Been Marked As Not Fetchable"