Commit 39f4e422 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower
Browse files

Fix to match the tf.gfile API change in tf2.0.

PiperOrigin-RevId: 288042402
parent 62bf6fc0
...@@ -102,7 +102,7 @@ class XLNetConfig(object): ...@@ -102,7 +102,7 @@ class XLNetConfig(object):
setattr(self, key, getattr(flags, key)) setattr(self, key, getattr(flags, key))
def init_from_json(self, json_path): def init_from_json(self, json_path):
with tf.gfile.Open(json_path) as f: with tf.io.gfile.GFile(json_path) as f:
json_data = json.load(f) json_data = json.load(f)
self.init_from_dict(json_data) self.init_from_dict(json_data)
...@@ -113,9 +113,9 @@ class XLNetConfig(object): ...@@ -113,9 +113,9 @@ class XLNetConfig(object):
json_data[key] = getattr(self, key) json_data[key] = getattr(self, key)
json_dir = os.path.dirname(json_path) json_dir = os.path.dirname(json_path)
if not tf.gfile.Exists(json_dir): if not tf.io.gfile.exists(json_dir):
tf.gfile.MakeDirs(json_dir) tf.io.gfile.makedirs(json_dir)
with tf.gfile.Open(json_path, 'w') as f: with tf.io.gfile.GFile(json_path, 'w') as f:
json.dump(json_data, f, indent=4, sort_keys=True) json.dump(json_data, f, indent=4, sort_keys=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment