将当前目录下cifar-10-batches-py转换成train图片和test图片,并同时生成train.txt 和 test.txt

这篇博客介绍了如何将CIFAR-10数据集的cifar-10-batches-py文件拆分为训练集和测试集,同时创建train.txt和test.txt文件以供后续训练和验证使用。详细步骤包括数据读取、拆分及文件生成过程。
摘要由CSDN通过智能技术生成
from __future__ import print_function
import matplotlib.pyplot as pyplot
import PIL.Image as Image
import pickle
import numpy as np
import random
import os,re

def unpickle(file):
    # data:a 10000x3072 numpy array of uint8s. Each row of the array stores a 32x32 colour image.
    # The first 1024 entries contain the red channel values, the next 1024 the green,
    # and the final 1024 the blue. The image is stored in row-major order,
    # so that the first 32 entries of the array are the red channel values of the first row of the image.

    # labels:a list of 10000 number
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值