I'm training a bijector using tensorflow-probability.
I'm following a tutorial. The same codes from the tutorial can be found at (the relevant part starts from the line "Training the bijector"): https://rpubs.com/bacti/tensorflow-probabilistic
My code is slightly different to the above. But even if I copy the same code from the above, it still causes the same error.
My codes is here (runnable). It's basically the same to the relevant part in the tutorial's codes: https://colab.research.google.com/drive/1tlA5l2ZGRIiR19HM-LHGKs-G2Rjxk6zF?usp=sharing#scrollTo=BW9Kmg3z0dzC
The training loop in my codes caused the error:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-13-3bf0f105e1c4> in <module>() 18 grads = tape.gradient(loss, trainable_dist.trainable_variables) 19 print('grads', grads) ---> 20 opt.apply_gradients(zip(grads, trainable_dist.trainable_variables)) 21 22 # print(loss) 1 frames /usr/local/lib/python3.7/dist-packages/keras/optimizer_v2/utils.py in filter_empty_gradients(grads_and_vars) 71 if not filtered: 72 variable = ([v.name for _, v in grads_and_vars],) ---> 73 raise ValueError(f"No gradients provided for any variable: {variable}. " 74 f"Provided `grads_and_vars` is {grads_and_vars}.") 75 if vars_with_empty_grads:
ValueError: No gradients provided for any variable: (['a:0', 'b:0'],). Provided `grads_and_vars` is ((None, <tf.Variable 'a:0' shape=() dtype=float32, numpy=0.25>), (None, <tf.Variable 'b:0' shape=() dtype=float32, numpy=-0.1>)).
The loss was computed, but the grads can not be computed in the line grads = tape.gradient(loss, trainable_dist.trainable_variables). They are (None, None). Why? What is the cause of it? I can't find any problem in my codes.
--
You received this message because you are subscribed to the Google Groups "TensorFlow Probability" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfprobabilit...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfprobability/5f495e2b-d272-48d9-b792-59591aab5a7dn%40tensorflow.org.