• 基本信息

  • 数据集下载解压后的目录结构:
  • 读取、打印和保存数据集中指定的图片:
    import pickle
    import matplotlib.pyplot as plt CIFAR_DIR ="cifar10_data/cifar-10-batches-bin/data_batch_1.bin"#数据集路径
    with open(CIFAR_DIR , 'rb') as f:
    data = pickle.load(f, encoding='bytes') print('----------batch1的基本信息-------------')
    print('data的数据类型:',type(data)) # 输出 <class 'dict'>
    print('字典的key名称:',data.keys()) # 输出 dict_keys([b'filenames', b'data', b'labels', b'batch_label'])
    print('bdata的数据类型',type(data[b'data'])) # 输出 <class 'numpy.ndarray'>
    print('bdata的数据形状',data[b'data'].shape) # 输出 (10000, 3072) 说明有 10000 个样本, 3072个特征 index=4#打印第几张图片
    print('-----------第%d张图片信息----------'%index)
    print('filenames:',data[b'filenames'][index])
    print('labels:',data[b'labels'][index])
    print('batch_label:',data[b'batch_label'][index])
    image_arr = data[b'data'][index] # 拿出 第 index 个样本
    image_arr = image_arr.reshape((3, 32, 32)) # 将一维向量改变形状得到这样一个元组:(高,宽,通道数)
    image_arr = image_arr.transpose((1, 2, 0))
    plt.imshow(image_arr) # 输出图片
    plt.savefig("cifar10_data/raw/%d.png"%index)#保存图片
    plt.show()
  • 打印出的图片

Tensorflow机器学习入门——cifar10数据集的读取、展示与保存的更多相关文章

  1. Tensorflow机器学习入门——MINIST数据集识别

    参考网站:http://www.tensorfly.cn/tfdoc/tutorials/mnist_beginners.html #自动下载并加载数据 from tensorflow.example ...

  2. Tensorflow机器学习入门——MINIST数据集识别(卷积神经网络)

    #自动下载并加载数据 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_s ...

  3. TensorFlow CNN 测试CIFAR-10数据集

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50738311 1 CIFAR-10 数 ...

  4. Tensorflow机器学习入门——读取数据

    TensorFlow 中可以通过三种方式读取数据: 一.通过feed_dict传递数据: input1 = tf.placeholder(tf.float32) input2 = tf.placeho ...

  5. Tensorflow机器学习入门——常量、变量、placeholder和基本运算

    一.这里列出了tensorflow的一些基本函数,比较全面:https://blog.csdn.net/M_Z_G_Y/article/details/80523834 二.这里是tensortflo ...

  6. Tensorflow机器学习入门——ModuleNotFoundError: No module named 'tensorflow.keras'

    这个bug的解决办法: # from tensorflow.keras import datasets, layers, models from tensorflow.python.keras imp ...

  7. Tensorflow机器学习入门——网络可视化TensorBoard

    一.在代码中标记要显示的各种量 tensorboard各函数的作用和用法请参考:https://www.cnblogs.com/lyc-seu/p/8647792.html import tensor ...

  8. Tensorflow机器学习入门——AttributeError: module 'scipy.misc' has no attribute 'toimage'

    这个bug的解决办法: import cv2 # scipy.misc.toimage(image_array).save('cifar10_data/raw/%d.jpg' % i) cv2.imw ...

  9. 利用Tensorflow读取二进制CIFAR-10数据集

    使用Tensorflow读取CIFAR-10二进制数据集 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 Tensorflow官方文档 tf.transpose函数解析 tf.sli ...

随机推荐

  1. Patter discovery VS clustering

    “pattern driven” (PD) is based on enumerating candidate patterns in a given solution space and picki ...

  2. 【Jmeter】jmeter提取response中的返回值,并保存到本地文件--BeanShell后置处理器

    有个需求,需要在压测环境中,创建几十万的账号数据,然后再根据创建结果,查询到某些账号信息. 按照之前我的做法,直接Python调用API,然后再数据库查询: 但是近期所有开发人员的数据库访问权限被限制 ...

  3. 数据库中查出来的时间多8小时&查询数据正常展示少8小时

    将serverTimezone的配置改为Asia/Shanghaiurl: jdbc:mysql://127.0.0.1:3306/bfc?useUnicode=true&characterE ...

  4. Django---Django返回用户输入数据

    前面写了关于HTML和Django结合的文章,通过视图与HTML结合,然后加上urls渲染返回给用户浏览器.很明显我们都能看到这些仅仅是静态HTML,那如何通过Django创建动态的HTML呢? 动态 ...

  5. AGC001 E - BBQ Hard [组合数]

    这题就是要求 \(\sum_{i=1}^{n} \sum_{j=i+1}^{n} C(a_i+a_j+b_i+b_j,a_i+a_j)\) 考虑搞一搞,\(C(a_i+a_j+b_i+b_j,a_i+ ...

  6. react 中 函数bind 和箭头函数

    用bind形式 方便测试,含有this时候最好用bind形 其他情况用箭头函数 含有this的时候也可以用箭头函数

  7. springboot+druid+mybatis plus的多数据源配置

    思路 yml中配置多个数据源信息 通过AOP切换不同数据源 配合mybatis plus使用 POM依赖 <dependency> <groupId>org.springfra ...

  8. Linux shell unzip和tar 批量解压文件

    #!/bin/sh UNTAR="tar -xvf " #unzip all zip files function unzip_all_file() { for i in *.zi ...

  9. 使用ADO.NET 查询和操作数据

    一.使用StringBuilder类追加和删除字符串 1.创建StringBuilder类的对象 StringBuilder sb=new StringBuilder("初始字符串值&quo ...

  10. div中宽高度自适应文字换行居中问题解决

    <html> <head> <meta charset="UTF-8"/> <title>div中宽高度自适应文字换行居中demo& ...