【问题标题】:when I practise the Mxnet turorial mnist, an error"ImportError: No module named mnist_demo" occurs当我练习 Mxnet turorial mnist 时,出现错误“ImportError: No module named mnist_demo”
【发布时间】:2017-04-25 13:55:27
【问题描述】:

教程位于http://mxnet.io/tutorials/python/mnist.html。 在这一步: "

from IPython.display import HTML
import cv2
import numpy as np
from mnist_demo import html, script
def classify(img):
    img = img[len('data:image/png;base64,'):].decode('base64')
    img = cv2.imdecode(np.fromstring(img, np.uint8), -1)
    img = cv2.resize(img[:,:,3], (28,28))
    img = img.astype(np.float32).reshape((1,1,28,28))/255.0
    return model.predict(img)[0].argmax()

'''
To see the model in action, run the demo notebook at
https://github.com/dmlc/mxnet-notebooks/blob/master/python/tutorials/mnist.ipynb.
'''
HTML(html + script)

"

ImportError Traceback(最近一次调用最后一次) 在 () 2 导入 cv2 3 将 numpy 导入为 np ----> 4 from mnist_demo import html, script 5 定义分类(img): 6 img = img[len('data:image/png;base64,'):].decode('base64')

ImportError: No module named mnist_demo

我不知道是什么原因,也无法在 Google 上找到答案。 有人知道吗?

【问题讨论】:

    标签: python mxnet


    【解决方案1】:

    那是因为教程没有写在一个文件中。您应该将mnist_demo.py 文件与您的教程笔记本放在一起。该文件可以在 github 站点上的 mxnet-notebooks 找到。 :P

    【讨论】:

    • 呃,你发这个问题是 8 天前。我想你一定已经解决了。
    猜你喜欢
    • 2017-03-16
    • 2015-04-30
    • 2017-08-20
    • 2015-02-27
    • 1970-01-01
    • 2014-05-11
    • 2018-08-26
    • 2013-08-20
    • 1970-01-01
    相关资源
    最近更新 更多