How to apply gradients later in tensorflow

Multi tool use


How to apply gradients later in tensorflow
I have a model where I computed the gradients manually over multiple examples. I have added the gradients manually, and now would like to do back propagation in tensorflow through:
prev_accum_grads = [tf.placeholder_with_default(input=tf.zeros(shape=var.get_shape().as_list(), dtype=m_dtype),
shape=var.get_shape().as_list(), name=var.name[:-2] + "_accum_grads")
for var in tf.trainable_variables()]
grads_and_vars = list(zip(prev_accum_grads, tf.trainable_variables()))
train_step = optimizer.apply_gradients(grads_and_vars)
Now, given the calculated gradients in prev_g[0], prev_g[1] ... prev_g[9]
as in the code below; and would like to apply the gradients as:
prev_g[0], prev_g[1] ... prev_g[9]
# prev_g is a list holding the values of the gradients.
feed_dict = {
prev_accum_grads[0]: prev_g[0], prev_accum_grads[1]: prev_g[1], prev_accum_grads[2]: prev_g[2],
prev_accum_grads[3]: prev_g[3], prev_accum_grads[4]: prev_g[4], prev_accum_grads[5]: prev_g[5],
prev_accum_grads[6]: prev_g[6], prev_accum_grads[7]: prev_g[7], prev_accum_grads[8]: prev_g[8],
prev_accum_grads[9]: prev_g[9],
}
_, train_summaries = sess.run([train_step, train_merged_summaries],
feed_dict=feed_dict)
so this code is throwing an error asking me to provide value to the input
placeholder.
input
so how to solve this problem?
Any help is much appreciated!!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.