資源簡(jiǎn)介
tensorflow實(shí)現(xiàn)服裝類(lèi)別分類(lèi),包括模型訓(xùn)練、驗(yàn)證及保存,例子本身從tensorflow官網(wǎng)學(xué)習(xí)而來(lái),親自進(jìn)行了實(shí)現(xiàn),代碼可用。環(huán)境搭建可參考個(gè)人博文。
代碼片段和文件信息
#!/usr/bin/env?python?
#?-*-?coding:utf-8?-*-
#?TensorFlow?and?tf.keras
import?tensorflow?as?tf
from?tensorflow?import?keras
#?Helper?libraries
import?numpy?as?np
import?matplotlib.pyplot?as?plt
fashion_mnist?=?keras.datasets.fashion_mnist
(train_images?train_labels)?(test_images?test_labels)?=?fashion_mnist.load_data()
class_names?=?[‘T-shirt/top‘?‘Trouser‘?‘Pullover‘?‘Dress‘?‘Coat‘
???????????????‘Sandal‘?‘Shirt‘?‘Sneaker‘?‘Bag‘?‘Ankle?boot‘]
train_images.shape;
train_labels_len?=?len(train_labels);
print(train_labels_len)
print(train_labels)
test_images.shape
test_labels_len?=?len(test_labels);
print(test_labels_len)
print(test_labels)
#?plt.figure()
#?plt.imshow(train_images[0])
#?plt.colorbar()
#?plt.grid(False)
#?plt.show()
train_images?=?train_images?/?255.0
test_images?=?test_images?/?255.0
#?plt.figure(figsize=(1010))
#?for?i?in?range(25):
#?????plt.subplot(55i+1)
#?????plt.xticks([])
#?????plt.yticks([])
#?????plt.grid(F
評(píng)論
共有 條評(píng)論