CreatTFrecoder.py 文件源码

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

项目:maliciou_code_cnn 作者: playgood111 项目源码 文件源码
def read_tfrecord(filename_queuetemp):
    filename_queue = tf.train.string_input_producer([filename_queuetemp])
    reader = tf.TFRecordReader()
    _, serialized_example = reader.read(filename_queue)
    features = tf.parse_single_example(
        serialized_example,
        features={
          'image_raw': tf.FixedLenFeature([], tf.string),
          'width': tf.FixedLenFeature([], tf.int64),
          'depth': tf.FixedLenFeature([], tf.int64),
          'label': tf.FixedLenFeature([], tf.int64)
      }
    )
    image = tf.decode_raw(features['image_raw'], tf.uint8)
    # image
    depth = features['depth']
    tf.reshape(image, [299, 299, 3])
    # normalize

    image = tf.cast(image, tf.float32) * (1. /255) - 0.5
    # label
    label = tf.cast(features['label'], tf.int32)
    return image, label
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号