无法在Keras中使用Tensorflow原生的Adam优化器

时间:2018-06-23 04:12:31

标签: python python-2.7 tensorflow keras

我正在Keras中使用Tensorflow本机优化程序Adam说,代码非常简单。但是,无论何时运行,它总是会失败,并显示以下错误:

File "/usr/local/lib/python2.7/dist-packages/keras/legacy/interfaces.p
y", line 87, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py"
, line 2016, in fit_generator


self._make_train_function()
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py"
, line 990, in _make_train_function
loss=self.total_loss)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/interfaces.p
y", line 87, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/optimizers.py", lin
e 630, in get_updates
grads, global_step=self.iterations)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/trainin
g/optimizer.py", line 486, in apply_gradients
update_ops.append(processor.update_op(self, grad))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/trainin
g/optimizer.py", line 113, in update_op
"Cannot use a constraint function on a sparse variable.")
RuntimeError: Cannot use a constraint function on a sparse variable.

0 个答案:

没有答案