inputs.py 文件源码

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

项目:text-classification2 作者: yuhui-lin 项目源码 文件源码
def read_and_decode_embedding(filename_queue):
    reader = tf.TFRecordReader()
    _, serialized_example = reader.read(filename_queue)
    features = tf.parse_single_example(
        serialized_example,
        # Defaults are not specified since both keys are required.
        features={
            'label': tf.FixedLenFeature(
                [], tf.int64),
            'sequence_raw': tf.FixedLenFeature(
                [], tf.string),
        })
    sequence = features['sequence_raw']

    # preprocess
    s_decode = tf.decode_raw(sequence, tf.int32)
    s_decode.set_shape([FLAGS.embed_length])

    # Convert label from a scalar uint8 tensor to an int32 scalar.
    label = tf.cast(features['label'], tf.int32)

    return s_decode, label
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号