<reponame>Jacob-Zhou/CWS_Dict-rewrite<filename>models/ModelConfig.py
import copy
import json
import six
import tensorflow as tf


class ModelConfig(object):
    def __init__(self, **kw):
        self.__dict__.update(kw)

    @classmethod
    def from_dict(cls, json_object):
        """Constructs a `BaselineConfig` from a Python dictionary of parameters."""
        config = cls()
        for (key, value) in six.iteritems(json_object):
            config.__dict__[key] = value
        return config

    @classmethod
    def from_json_file(cls, json_file):
        """Constructs a `BertConfig` from a json file of parameters."""
        with tf.gfile.GFile(json_file, "r") as reader:
            text = reader.read()
        return cls.from_dict(json.loads(text))

    def to_dict(self):
        """Serializes this instance to a Python dictionary."""
        output = copy.deepcopy(self.__dict__)
        return output

    def to_json_string(self):
        """Serializes this instance to a JSON string."""
        return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"


import copy
import json
import six
import tensorflow as tf


class ModelConfig(object):
    def __init__(self, **kw):
        self.__dict__.update(kw)

    @classmethod
    def from_dict(cls, json_object):
        """Constructs a `BaselineConfig` from a Python dictionary of parameters."""
        config = cls()
        for (key, value) in six.iteritems(json_object):
            config.__dict__[key] = value
        return config

    @classmethod
    def from_json_file(cls, json_file):
        """Constructs a `BertConfig` from a json file of parameters."""
        with tf.gfile.GFile(json_file, "r") as reader:
            text = reader.read()
        return cls.from_dict(json.loads(text))

    def to_dict(self):
        """Serializes this instance to a Python dictionary."""
        output = copy.deepcopy(self.__dict__)
        return output

    def to_json_string(self):
        """Serializes this instance to a JSON string."""
        return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"
Constructs a `BaselineConfig` from a Python dictionary of parameters. Constructs a `BertConfig` from a json file of parameters. Serializes this instance to a Python dictionary. Serializes this instance to a JSON string.