日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

import minist时候报错No module named mnist如何解决

發布時間:2024/1/18 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 import minist时候报错No module named mnist如何解决 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import minist的時候報錯:
No module named ‘mnist’

部分代碼:

import mnist import numpy as np from conv import Conv3x3 from maxpool import MaxPool2 from softmax import Softmax# 訓練集文件 #train_images_idx3_ubyte_file = '../../data/mnist/bin/train-images.idx3-ubyte' # 訓練集標簽文件 #train_labels_idx1_ubyte_file = '../../data/mnist/bin/train-labels.idx1-ubyte'# 測試集文件 test_images_idx3_ubyte_file = r't10k-images.idx3-ubyte' # 測試集標簽文件 test_labels_idx1_ubyte_file = r't10k-labels.idx1-ubyte'#我們只使用前1K測試示例(全部是10K個)。為了時間的利益。如果你想的話,可以隨意改變 test_images = mnist.test_images()[:1000] test_labels = mnist.test_labels()[:1000]conv = Conv3x3(8) # 28x28x1 -> 26x26x8 pool = MaxPool2() # 26x26x8 -> 13x13x8 softmax = Softmax(13 * 13 * 8, 10) # 13x13x8 -> 10def forward(image, label):#完成CNN的前向傳遞并計算準確度和交叉熵損失。#圖像是二維numpy數組。標簽是數字#我們將圖像從[0,255]轉換為[-0.5,0.5]以使其更容易。一起工作。這是標準做法。out = conv.forward((image / 255) - 0.5)out = pool.forward(out)out = softmax.forward(out)# 計算交叉熵損失和精度。np.log() 是自然日志loss = -np.log(out[label])acc = 1 if np.argmax(out) == label else 0return out, loss, accprint('MNIST CNN 初始化!') loss = 0 num_correct = 0for i, (im, label) in enumerate(zip(test_images, test_labels)):# 向前傳遞_, l, acc = forward(im, label)loss += lnum_correct += acc# 每100步打印一次統計數據if i % 100 == 99:print('[Step %d] Past 100 steps: Average Loss %.3f | Accuracy: %d%%'%(i + 1, loss/100, num_correct) )loss = 0num_correct = 0

整體代碼鏈接:
https://blog.csdn.net/zimiao552147572/article/details/92801266

初次懷疑是不是被刪了,因為都是tensorflow在使用minist。
import沒有錯,錯的是確實有這個包,需要pip導入

pip install mnist(不要打錯mnist)
希望能幫助我,謝謝!

總結

以上是生活随笔為你收集整理的import minist时候报错No module named mnist如何解决的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。