# Defining the tf ops
prob_placeholder = tf.placeholder(tf.float32, shape=(2))
log_placeholder = tf.log(prob_placeholder)
grads_placeholder = tf.gradients(ys=tf.log(prob_placeholder), xs=model.weights)
# t is some index into the holders (which are lists)
# s is some state || p_a is some list of [p_1, 1 - p_1] || a_ is either 0 or 1 || r is 1
prob_ = tf_sess.run(prob_placeholder, {prob_placeholder: p_a})
log_ = tf_sess.run(log_placeholder, {prob_placeholder: prob_})
print(prob_, log_)
grads_ = tf_sess.run(grads_placeholder, {prob_placeholder: prob_})
Basically I'm not sure why it's returning None.
TypeError: Fetch argument None has invalid type <type 'NoneType'>
I've tried adding print statements and I can see prob_ and log_ come out just fine but I'm not sure what's happening in tf.gradients that is causing the issue above.
model.weights are basically the weights of the model that I'm using.
prob_placeholder
does not have any explicit dependence on model.weights
, i.e. it is not functionally dependent on model.weights
the way you have defined them.
Hence, though technically the gradient should be zero, it is computed as None
due to technical reasons in TensorFlow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With