You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue with _create_slots: var_list[0].device empty #333
Traceback (most recent call last):
File "test/test.py", line 66, in <module>
train_loss = tf.train.AdamOptimizer(learning_rate=0.01).minimize(loss) # Adam Optimizer
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 167, in minimize
name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 245, in apply_gradients
self._create_slots([v for g, v in grads_and_vars if g is not None])
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/adam.py", line 87, in _create_slots
with ops.device(var_list[0].device):
IndexError: list index out of range
But this is working: (only call function from another file is not)
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(activation, y))
train_loss = self.optimizer(learning_rate=0.01).minimize(loss)
It seemed I can't define that expression outside the main thread, I also tried using same graph as default graph, but it doesn't seem to work either. I think this is an issue with graph building.
If you ever ran into this problem, thanks for helping!
The error indicates that the optimizer could not find any gradients for the variables to optimize.
This can be caused by several problems:
1- The optimizer could not find any variable to optimize.
2- The loss does not depend on any variable.
For 1-: Optimizers look for trainable variables in the default graph. They use tf.trainable_variables() as the list of variables to optimize. So try calling that function and print its output before calling .minimize(). If you get an empty list then the optimizer won't find variables either.
Maybe you have not created any variables? Or you only create variables with trainable=False?
For 2-: The optimizer computes gradients of the loss with respect to variables. If there are no variables there are no gradients and nothing to optimize. For example, if you pass a constant to minimize() nothing can be done. Now, the fact that you say it works when called from the same file seems to rule out that possibility, but check anyway.
Finally: The error message clearly needs to be improved.
Activity
touts commentedon Nov 25, 2015
The error indicates that the optimizer could not find any gradients for the variables to optimize.
This can be caused by several problems:
1- The optimizer could not find any variable to optimize.
2- The loss does not depend on any variable.
For 1-: Optimizers look for trainable variables in the default graph. They use
tf.trainable_variables()as the list of variables to optimize. So try calling that function and print its output before calling.minimize(). If you get an empty list then the optimizer won't find variables either.Why can't it find variables?
tf.get_default_graph()andGraph.as_default()in http://tensorflow.org/api_docs/python/framework.md#Graph .trainable=False?For 2-: The optimizer computes gradients of the loss with respect to variables. If there are no variables there are no gradients and nothing to optimize. For example, if you pass a constant to
minimize()nothing can be done. Now, the fact that you say it works when called from the same file seems to rule out that possibility, but check anyway.Finally: The error message clearly needs to be improved.
vrv commentedon Dec 23, 2015
Closing due to staleness, I think we committed a change a few weeks ago that fixed the error message to be better. Let us know if that's not true!
typo fix (tensorflow#333)
Update XNNPACK in XLA