read_data.py 文件源码

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

项目:CellDetection 作者: quqixun 项目源码 文件源码
def decode_record(filename_queue, patch_size,
                  channel_num=3):
    reader = tf.TFRecordReader()
    _, serialized_example = reader.read(filename_queue)
    features = tf.parse_single_example(
        serialized_example,
        features={
            'label': tf.FixedLenFeature([], tf.int64),
            'image': tf.FixedLenFeature([], tf.string),
        })

    img = tf.decode_raw(features['image'], tf.uint8)
    img = tf.reshape(img, [patch_size, patch_size, channel_num])
    img = tf.cast(img, tf.float32) * (1. / 255) - 0.5
    label = tf.cast(features['label'], tf.int32)

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


问题


面经


文章

微信
公众号

扫码关注公众号