从Tensorflow转换元数据架构中提取信息

时间:2019-05-26 21:56:42

标签: tensorflow tensorflow-transform

保存了一个转换管道模型(工件,tfrecords等)。输入数据的功能包含词汇(通过tft.compute_and_apply_vocabulary创建)。
读取保存的数据后,我现在需要有关词汇的信息以创建我的model_fn。

我找到了一种方法,但是想知道是否有更清洁的方法。 这是我的代码:

transformed_metadata = metadata_io.read_metadata(os.path.join(ARTIFACT_DIR, "transformed_metadata"))
tfdv.get_domain(transformed_metadata.schema.__dict__['_schema_proto'], 'text')

产生(根据需要):

  

min:-1 max:21424 is_categorical:true

schema.pbtxt看起来像这样:

feature {
  name: "text"
  type: INT
  int_domain {
    min: -1
    max: 21424
    is_categorical: true
  }
}
feature {
  name: "updown"
  type: INT
  presence {
    min_fraction: 1.0
  }
  shape {
    dim {
      size: 2
    }
  }
}

0 个答案:

没有答案