cifar10.py 文件源码

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

项目:reslearn 作者: mackcmillion 项目源码 文件源码
def _read_image(filename_queue):
        # copied from
        # https://tensorflow.googlesource.com/tensorflow/+/master/tensorflow/models/image/cifar10/cifar10_input.py

        # CIFAR-10 specification
        label_bytes = 1
        height = 32
        width = 32
        depth = 3

        image_bytes = height * width * depth
        record_bytes = label_bytes + image_bytes
        reader = tf.FixedLengthRecordReader(record_bytes=record_bytes)
        _, value = reader.read(filename_queue)
        record_bytes = tf.decode_raw(value, tf.uint8)

        label = tf.cast(tf.slice(record_bytes, [0], [label_bytes]), tf.int32)
        depth_major = tf.reshape(tf.slice(record_bytes, [label_bytes], [image_bytes]),
                                 [depth, height, width])
        uint8image = tf.transpose(depth_major, [1, 2, 0])
        image = tf.cast(uint8image, tf.float32)
        return image, tf.squeeze(label)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号