Fix the Tensorflow/Keras Tests
chukarsten opened this issue · 0 comments
chukarsten commented
With #1 we skipped the Tensorflow/Keras tests (some of them) to keep things green for most non-tf users going forward. We'd like to fix them, though.
The tests that are failing:
FAILED tests/explainers/test_deep.py::test_tf_keras_mnist_cnn - AttributeError: 'Adam' object has no attribute 'get_updates'
FAILED tests/explainers/test_deep.py::test_tf_keras_linear - AttributeError: 'SGD' object has no attribute 'get_updates'
FAILED tests/explainers/test_gradient.py::test_tf_keras_mnist_cnn - AttributeError: 'Adadelta' object has no attribute 'get_updates'
Stack Trace:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/keras/engine/training_v1.py:873: in fit
use_multiprocessing=use_multiprocessing,
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/keras/engine/training_arrays_v1.py:751: in fit
steps_name="steps_per_epoch",
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/keras/engine/training_arrays_v1.py:192: in model_iteration
f = _make_execution_function(model, mode)
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/keras/engine/training_arrays_v1.py:620: in _make_execution_function
return model._make_execution_function(mode)
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/keras/engine/training_v1.py:2364: in _make_execution_function
self._make_train_function()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <keras.engine.sequential.Sequential object at 0x7fdfe6e91ed0>
def _make_train_function(self):
has_recompiled = self._recompile_weights_loss_and_weighted_metrics()
self._check_trainable_weights_consistency()
if isinstance(self.optimizer, list):
raise ValueError(
"The `optimizer` in `compile` should be a single optimizer."
)
# If we have re-compiled the loss/weighted metric sub-graphs then create
# train function even if one exists already. This is because
# `_feed_sample_weights` list has been updated on re-compile.
if getattr(self, "train_function", None) is None or has_recompiled:
# Restore the compiled trainable state.
current_trainable_state = self._get_trainable_state()
self._set_trainable_state(self._compiled_trainable_state)
inputs = (
self._feed_inputs
+ self._feed_targets
+ self._feed_sample_weights
)
if not isinstance(backend.symbolic_learning_phase(), int):
inputs += [backend.symbolic_learning_phase()]
with backend.get_graph().as_default():
with backend.name_scope("training"):
# Training updates
> updates = self.optimizer.get_updates(
params=self._collected_trainable_weights,
loss=self.total_loss,
)
E AttributeError: 'Adam' object has no attribute 'get_updates'
It's unclear what's going on as the error is being thrown in keras Engine code that's calling the get_updates()
function on a keras optimizer object. We need to figure out what's going on - fix it - then unskip the three tests above.