keras调用tensorborad时报错 AttributeError 'Model' object has no attribute '_get_distribution_strategy'
keras调用tensorborad时报错:AttributeError: 'Model' object has no attribute '_get_distribution_strategy'
软件版本:
- python: 3.7.4
 - keras: 2.3.1
 - tensorboard: 2.1.0
 - tensorflow: 2.1.0
 
解决办法A:
- 参考tensorflow的 pull #34870 : “Use _get_distribution_strategy only when it is available. “ https://github.com/tensorflow/tensorflow/pull/34870
 
The changes introduced in 06d8f77 are not compatible with standalone
Keras(they are compatible withtf.Keras). akeras.Modeldoes not have a_get_distribution_strategymethod, which is now assumed for theTensorboardcallback.
- 直接修改
tensorflow/python/keras/callbacks.py文件,如下图。 
相关代码如下。
1  | # 1529行左右 : # distributed_file_utils.write_dirpath()  | 
解决办法B:
修改引用,改为从tensorflow.keras中引用。
1  | import keras  |