vendredi 2 décembre 2016

tensorflow: cond op: TypeError: fn1 must be callable

I would like to use tf.cond() to make a condition choose. Here is the code:

    def choose_imgs1(self, imgs):
        a = tf.Print(imgs, [imgs.get_shape()], message='(odd epoch) input image batch shape:')
        return a
    def choose_imgs2(self, imgs):
        a = tf.Print(imgs, [imgs.get_shape()], message='(even epoch) input image batch shape:')
        return a

    self.images = tf.cond(tf.equal(tf.mod(self.epoch_num, 2), 0), self.choose_imgs2(self.images2), self.choose_imgs1(self.images1))

But when I execute it, there comes the following error:

  File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 1692, in cond
    raise TypeError("fn1 must be callable.")

TypeError: fn1 must be callable.

How to solve that?

Aucun commentaire:

Enregistrer un commentaire