def _from_domain_dict(domain):
"""Translate a JSON domain dict into a Domain."""
if domain.get('ints') is not None:
def maybe_to_int(s):
return int(s) if s is not None else None
return sch.IntDomain(
tf.int64,
maybe_to_int(domain['ints'].get('min')),
maybe_to_int(domain['ints'].get('max')),
domain['ints'].get('isCategorical'),
domain['ints'].get('vocabularyFile', ''))
if domain.get('floats') is not None:
return sch.FloatDomain(tf.float32)
if domain.get('strings') is not None:
return sch.StringDomain(tf.string)
if domain.get('bools') is not None:
return sch.BoolDomain(tf.bool)
raise ValueError('Unknown domain: {}'.format(domain))
评论列表
文章目录