tensorflow2之fashion_minist测试

下面做的是一个多分类的经典例子,加载编号(0-9)的10种商品的fashion_minist数据集进行测试。

FashionMNIST 是一个替代 MNIST 手写数字集 的图像数据集。 它是由 Zalando(一家德国的时尚科技公司)旗下的研究部门提供。其涵盖了来自 10 种类别的共 7 万个不同商品的正面图片。 

https://github.com/zalandoresearch/fashion-mnist

创建 fashion_minist_tf.py

#encoding=utf-8
# 多分类问题

import pandas as pd
import matplotlib.pyplot as plt
# from matplotlib.font_manager import FontProperties
import tensorflow as tf


(train_image,train_label),(test_image,test_label) = tf.keras.datasets.fashion_mnist.load_data()

plt.imshow(train_image[0]) # 显示第一张图片
plt.show()

print(train_label[:10]) # [9 0 0 3 0 2 7 2 5 5]


train_image = train_image / 255 
test_image = test_image /255 

print(train_image.shape)  # (60000, 28, 28)

model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten(input_shape=(28,28)))
model.add(tf.keras.layers.Dense(units=
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值