aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/keras/python/keras/backend.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/keras/python/keras/backend.py')
-rw-r--r--tensorflow/contrib/keras/python/keras/backend.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tensorflow/contrib/keras/python/keras/backend.py b/tensorflow/contrib/keras/python/keras/backend.py
index 1882ae35f5..d149138796 100644
--- a/tensorflow/contrib/keras/python/keras/backend.py
+++ b/tensorflow/contrib/keras/python/keras/backend.py
@@ -3625,3 +3625,23 @@ if os.path.exists(_config_path):
set_floatx(_floatx)
set_epsilon(_epsilon)
set_image_data_format(_image_data_format)
+
+# Save config file.
+if os.access(_keras_base_dir, os.W_OK):
+ if not os.path.exists(_keras_dir):
+ try:
+ os.makedirs(_keras_dir)
+ except OSError:
+ # Except potential race conditions
+ # in multi-threaded environments.
+ pass
+
+ if not os.path.exists(_config_path):
+ _config = {
+ 'floatx': floatx(),
+ 'epsilon': epsilon(),
+ 'backend': 'tensorflow',
+ 'image_data_format': image_data_format()
+ }
+ with open(_config_path, 'w') as f:
+ f.write(json.dumps(_config, indent=4))