When running the tutorial notebook Gaussian Process Regression in TensorFlow Probability in Google Colab I run into
the following issue:
I execute the code cells in order, without changing any code. The cell containing the following code produces an error.
# Now we optimize the model parameters.
num_iters = 1000
optimizer = tf.optimizers.Adam(learning_rate=.01)
# Store the likelihood values during training, so we can plot the progress
lls_ = np.zeros(num_iters, np.float64)
for i in range(num_iters):
with tf.GradientTape() as tape:
loss = -target_log_prob(amplitude_var, length_scale_var,
observation_noise_variance_var)
grads = tape.gradient(loss, trainable_variables)
optimizer.apply_gradients(zip(grads, trainable_variables))
lls_[i] = loss
print('Trained parameters:')
print('amplitude: {}'.format(amplitude_var._value().numpy()))
print('length_scale: {}'.format(length_scale_var._value().numpy()))
print('observation_noise_variance: {}'.format(observation_noise_variance_var._value().numpy()))
The error message is:
ValueError Traceback (most recent call last)
<ipython-input-81-0b42fdbef836> in <module>()
10 observation_noise_variance_var)
11 grads = tape.gradient(loss, trainable_variables)
---> 12 optimizer.apply_gradients(zip(grads, trainable_variables))
13 lls_[i] = loss
14
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/optimizer_v2/utils.py in filter_empty_gradients(grads_and_vars)
74 if not filtered:
75 raise ValueError("No gradients provided for any variable: %s." %
---> 76 ([v.name for _, v in grads_and_vars],))
77 if vars_with_empty_grads:
78 logging.warning(
ValueError: No gradients provided for any variable: ['amplitude:0', 'length_scale:0', 'observation_noise_variance_var:0'].
After consulting Stack Overflow I tried adding tape.watch(trainable_variables), but this did not change anything.
Might someone be able to help figure out why this is happening?
When running the tutorial notebook Gaussian Process Regression in TensorFlow Probability in Google Colab I run into
the following issue:
I execute the code cells in order, without changing any code. The cell containing the following code produces an error.
The error message is:
After consulting Stack Overflow I tried adding
tape.watch(trainable_variables), but this did not change anything.Might someone be able to help figure out why this is happening?