I'm trying to sample a random vector from a tfd distribution. When trying to call the function inside the train_step called from the fit function of a keras subclassed model the batch shape gets automatically removed and defined as None. Is it possible to get around this problem? I see that in the docs of the Distribution class the shape of the sample must be statically known. The issue is not present using tf.keras.backend.random_normal function. It think this is a similar issue to #425, where keras.Input is used.
You can find this sample code to replicate the issue.
random normal from tf.keras.backend shape: (None, 2)
tf.shape: Tensor("cm_35/Shape:0", shape=(3,), dtype=int32), inputs.shape:(None, 10, 2)
ValueError: Cannot convert a partially known TensorShape to a Tensor: (None, 2)
I'm trying to sample a random vector from a tfd distribution. When trying to call the function inside the train_step called from the fit function of a keras subclassed model the batch shape gets automatically removed and defined as None. Is it possible to get around this problem? I see that in the docs of the Distribution class the shape of the sample must be statically known. The issue is not present using tf.keras.backend.random_normal function. It think this is a similar issue to #425, where keras.Input is used.
You can find this sample code to replicate the issue.
which outputs: