CIFAR-10图像识别案例的TensorFlow实例

下面是一个使用TensorFlow实现CIFAR-10图像识别的示例代码:

import tensorflow as tf
from tensorflow.keras.datasets import cifar10

# 加载CIFAR-10数据集,会自动下载(如果之前没下载过)
(x_train, y_train), (x_test, y_test) = cifar10.load_data()

# 查看训练集信息
print("训练集图像形状:", x_train.shape)
print("训练集标签形状:", y_train.shape)

# 查看测试集信息
print("测试集图像形状:", x_test.shape)
print("测试集标签形状:", y_test.shape)

plt.mishow(x_train[6])
y_train

label_dict = {0:"airplane", 1:"automobile", 2:"bird", 3:"cat", 4:"deer",
              5:"dog", 6:"frog", 7:"horse", 8:"ship", 9:"truck"}
label_dict[y_train[6][0]]

x_train[0][0][0]
x_train = x_train.astype("float32")/255.0
x_test = x_test.astype("float32")/255.0

model = tf.keras.models.Sequential()

model.add(tf.keras.layers.Conv2D(filters=32,
                                 kernel_size
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值