Tensorflow机器学习入门——cifar10数据集的读取、展示与保存
- 基本信息
- 官网:http://www.cs.toronto.edu/~kriz/cifar.html
- 共60000张图片:50000张用于训练、10000张用于测试
- 图片大小为:32X32
- 数据集图片分为10类:每类6000张
- 数据集下载解压后的目录结构:
- 读取、打印和保存数据集中指定的图片:
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数据集的读取、展示与保存的更多相关文章
- Tensorflow机器学习入门——MINIST数据集识别
参考网站:http://www.tensorfly.cn/tfdoc/tutorials/mnist_beginners.html #自动下载并加载数据 from tensorflow.example ...
- Tensorflow机器学习入门——MINIST数据集识别(卷积神经网络)
#自动下载并加载数据 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_s ...
- TensorFlow CNN 测试CIFAR-10数据集
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50738311 1 CIFAR-10 数 ...
- Tensorflow机器学习入门——读取数据
TensorFlow 中可以通过三种方式读取数据: 一.通过feed_dict传递数据: input1 = tf.placeholder(tf.float32) input2 = tf.placeho ...
- Tensorflow机器学习入门——常量、变量、placeholder和基本运算
一.这里列出了tensorflow的一些基本函数,比较全面:https://blog.csdn.net/M_Z_G_Y/article/details/80523834 二.这里是tensortflo ...
- Tensorflow机器学习入门——ModuleNotFoundError: No module named 'tensorflow.keras'
这个bug的解决办法: # from tensorflow.keras import datasets, layers, models from tensorflow.python.keras imp ...
- Tensorflow机器学习入门——网络可视化TensorBoard
一.在代码中标记要显示的各种量 tensorboard各函数的作用和用法请参考:https://www.cnblogs.com/lyc-seu/p/8647792.html import tensor ...
- 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 ...
- 利用Tensorflow读取二进制CIFAR-10数据集
使用Tensorflow读取CIFAR-10二进制数据集 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 Tensorflow官方文档 tf.transpose函数解析 tf.sli ...
随机推荐
- Quartz.NET - 教程 4: 更多关于触发器
译者注: 目录在这 [译]Quartz.NET 3.x 教程 译者注: 原文在这 Lesson 4: More About Triggers 跟作业一样, 触发器也相当容易使用, 但确实包含各种可定制 ...
- Django---Django返回HTML文件
前面我们简单的了解Django的一些工作原理,其中关于页面展示的内容,也全部都是视图(Views)返回的内容,那么我们也知道前端包括很多内容.如:HTML,CSS,JavaScript等以及各种插件, ...
- NC反弹shell的几种方法
假如ubuntu.CentOS为目标服务器系统 kali为攻击者的系统,ip为:192.168.0.4,开放7777端口且没被占用 最终是将ubuntu.CentOS的shell反弹到kali上 正向 ...
- python3包、模块、类、方法的认识
包>>模块>>类>> 函数 包:就是一个目录,import time from+import导入包中的部分模块 直接到类 from budaoguan.common ...
- JS 动态改变浏览器title标题
onfocus 和 onblur 事件,监听离开页面和进入页面 <script> window.onfocus = function () { document.title = '要走的人 ...
- ASP.NET Core 2.1 中的 HttpClientFactory (Part 4) 整合Polly实现瞬时故障处理
原文:https://www.stevejgordon.co.uk/httpclientfactory-using-polly-for-transient-fault-handling发表于:2018 ...
- react-native构建基本页面2---轮播图+九宫格
配置首页的轮播图 轮播图官网 运行npm i react-native-swiper --save安装轮播图组件 导入轮播图组件import Swiper from 'react-native-swi ...
- immutability-helper 用途+使用方法
1.react 官网文章 2.github地址
- 获取url参数(jq 扩展包)
(function($){ $.extend({ urlGet:function(url) { var getUrl = url ? url.split("?") : window ...
- php文件上传 form表单形式
1.php界面 <?php header( 'Content-Type:text/html;charset=utf-8 ');include_once("conn/conn.php&q ...