schema_io_v1_json_reader.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:transform 作者: tensorflow 项目源码 文件源码
def _from_sparse_feature_dict(feature_dict):
  """Translate a JSON sparse feature dict into a ColumnSchema."""
  # assume there is only one value column
  value_feature = feature_dict['valueFeature'][0]
  domain = _from_domain_dict(value_feature['domain'])

  index_feature_dicts = feature_dict['indexFeature']

  # int() is needed because protobuf JSON encodes int64 as string
  axes = [sch.Axis(int(index_feature_dict['size']))
          for index_feature_dict in index_feature_dicts]

  value_field_name = value_feature['name']
  index_fields = [sch.SparseIndexField(index_feature_dict['name'],
                                       index_feature_dict['isSorted'])
                  for index_feature_dict in index_feature_dicts]

  representation = sch.SparseColumnRepresentation(value_field_name,
                                                  index_fields)

  return sch.ColumnSchema(domain, axes, representation)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号