Fix problem with Tensorflow input_lib missing attribute DistributedDatasetInterface
Apparently there is no need for the past when you develop with Tensorflow. I dared an attempt to load and use a year old Tensorflow/Keras model but tripped on the error:
AttributeError: module 'tensorflow.python.distribute.input_lib'
has no attribute 'DistributedDatasetInterface'
There seems to be consensus that the issue is caused by the first-rate decision to include an old version of Keras in the tensorflow.python.keras
part of the Tensorflow distribution.
Here is what worked for me, monkey patching the data_adapter
:
from tensorflow.python.keras.engine import data_adapter
def _is_distributed_dataset(ds):
return isinstance(ds, data_adapter.input_lib.DistributedDatasetSpec)
data_adapter._is_distributed_dataset = _is_distributed_dataset
With this patch I was able to load and use the model. YMMV!