在optimize.py的apply_gradients中的ValueError(“没有提供变量。”)

时间:2017-04-04 18:47:16

标签: tensorflow deep-learning

optimizer.py中,代码段的第一部分是

def apply_gradients(self, grads_and_vars, global_step=None, name=None):

   grads_and_vars = tuple(grads_and_vars)  # Make sure repeat iteration works.
   if not grads_and_vars:
      raise ValueError("No variables provided.")

运行我的程序,我收到了由此特定错误引起的错误消息。然后我打印出tuple(grads_and_vars),其中一部分是。{1}}。我不知道为什么它会导致no variables provided的错误。

((<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_0:0' shape=(3, 3, 3, 64) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2afc746b5c50>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_1:0' shape=(64,) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2affd48189b0>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_2:0' shape=(3, 3, 64, 64) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2affd486d940>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_3:0' shape=(64,) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2affd488cf98>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_4:0' shape=(3, 3, 64, 128) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2afc746b5d68>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_5:0' shape=(128,) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2affd48f4278>), (<tf.Tensor 'Optimizer/training/clip_by_global_norm/Optimizer/training/clip_by_global_norm/_6:0' shape=(3, 3, 128, 128) dtype=float32>, <tensorflow.python.ops.variables.Variable object at 0x2affd4915e10>), 

1 个答案:

答案 0 :(得分:0)

在你的情况下,也许你应该尝试grads_and_vars = list(zip(grads,var_list))