nengo / nengo-dl

Deep learning integration for Nengo
https://www.nengo.ai/nengo-dl
Other
88 stars 22 forks source link

Fix TF2.2 compatibility issue in tensorflow-models example #153

Closed drasmuss closed 4 years ago

drasmuss commented 4 years ago

TensorFlow 2.2 causes an issue with the KerasWrapper class. They added a new version of the Layer class, in base_layer.py, and moved the old version to base_layer_v1.py. The problem is caused by this new version of the metrics property https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/python/keras/engine/base_layer.py#L1306, which checks the _metrics_lock attribute on all the sub-layers. However, if those sub-layers are base_layer_v1 layers, then that _metrics_lock property doesn't exist and it crashes. The unusual setup of the KerasWrapper class leads to that situation, so it is fixed here by just manually patching in the missing attribute.

It's kind of an ugly fix, but also a somewhat temporary one. Once we switch Nengo DL to being natively eager (which is planned for the next release), then all the layers should be the updated base_layer.py version and this won't be an issue any more.

Also updated the remote docs script so that it stops uploading broken doc builds.

drasmuss commented 4 years ago

Added various fixes for this issue https://github.com/tensorflow/tensorflow/issues/39456 (basically ensuring that we're explicitly using the values returned from evaluate rather than relying on them being automatically printed to stdout).