add to_json_file method to configuration classes

This commit is contained in:
thomwolf
2019-04-15 14:12:08 +02:00
parent b17963d82f
commit 9761aa4845
8 changed files with 56 additions and 0 deletions

View File

@@ -225,6 +225,11 @@ class OpenAIGPTConfig(object):
"""Serializes this instance to a JSON string."""
return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"
def to_json_file(self, json_file_path):
""" Save this instance to a json file."""
with open(json_file_path, "w", encoding='utf-8') as writer:
writer.write(self.to_json_string())
class Conv1D(nn.Module):
def __init__(self, nf, rf, nx):