def _raw_features_to_dense_tensor(raw_features):
"""Convert the raw features expressing a sparse vector to a dense tensor.
Args:
raw_features: Parsed features in sparse matrix format.
Returns:
A dense tensor populated with the raw features.
"""
# Load the vocabulary here as each batch of examples is parsed to ensure that
# the examples and the mapping table are located in the same TensorFlow graph.
measurement_table = tf.contrib.lookup.index_table_from_file(
vocabulary_file=FLAGS.vocabulary_file)
tf.logging.info("Loaded vocabulary file %s with %s terms.",
FLAGS.vocabulary_file, str(measurement_table.size()))
indices = measurement_table.lookup(raw_features[MEASUREMENTS_FEATURE])
merged = tf.sparse_merge(
indices,
raw_features[VALUES_FEATURE],
vocab_size=measurement_table.size())
return tf.sparse_tensor_to_dense(merged)
cluster_measurements.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录