tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.24k stars 1.09k forks source link

DistributionLambda in conjunction with TransformedDistribution and ScalarFunctionWithInferredInverse raises Exception #1566

Open MArpogaus opened 2 years ago

MArpogaus commented 2 years ago

Hello,

I am using:

I am training a simple model on a density estimation task.

When using a DistributionLambda in conjunction with a TransformedDistribution and a ScalarFunctionWithInferredInverse bijector i get the following Exception:

ValueError: Exception encountered when calling layer "distribution_lambda" (type DistributionLambda).

Cannot infer tensor rank of objective values.

Call arguments received:
  • inputs=tf.Tensor(shape=(None, 12), dtype=float32)
  • args=<class 'inspect._empty'>
  • kwargs={'training': 'None'}
Error: Process completed with exit code 1.

[Full Traceback]

However, using the same distribution as a custom Loss function works.

hjlgood commented 1 year ago

I would like to use TransformedDistribution as an output of DistributionLambda as well. It would be helpful if there's a way to use more customized distribution other than Normal, Binomial etc.