0
def get_z(epsilon):
    return tf.cond(flag,lambda: mean + sigma*epsilon,lambda: epsilon)

In this, when I call the function with flag = True, I have my mean and sigma tensors defined and epsilon is the placeholder I give, and it works well.

If I call it with flag = False, I have to simply return epsilon, the placeholder I give. But at this stage, the mean and sigma are not defined as I am not providing the data to compute mean and sigma. However that shouldn't matter because mean and sigma are not needed. But running this is throwing the error to define mean and sigma. Is there any work-around for this?

Thank you.

Sarthak Mittal
  • 154
  • 3
  • 9

1 Answers1

0

mean and sigma should be defined as the lambda function depends on the two values, you may use them as function input. Two placeholders with mean and sigma may be used.

def get_z(epsilon, mean, sigma):
    return tf.cond(flag,lambda: mean + sigma*epsilon,lambda: epsilon)
Ishant Mrinal
  • 4,898
  • 3
  • 29
  • 47