【发布时间】:2016-01-18 11:00:24
【问题描述】:
我正在尝试编译和运行发布在here 的 sn-ps,它基本上可以让我可视化网络内部结构(特征图)。
我已经使用caffe-windows 分支成功编译了caffe 和pycaffe,并且我已经将caffe 文件夹复制到了T:\Anaconda\Lib\site-packages 文件夹中。
然而,当我尝试在 jupyter notebook 中运行这段代码时:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Make sure that caffe is on the python path:
caffe_root = 'TC:/Caffe/' # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
plt.rcParams['figure.figsize'] = (10, 10)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
import os
if not os.path.isfile(caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'):
print("Downloading pre-trained CaffeNet model...")
!../scripts/download_model_binary.py ../models/bvlc_reference_caffenet
我收到以下错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-e7a8ec94e861> in <module>()
8 sys.path.insert(0, caffe_root + 'python')
9
---> 10 import caffe
L:\Anaconda2\lib\site-packages\caffe\__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver
2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver
3 from .proto.caffe_pb2 import TRAIN, TEST
4 from .classifier import Classifier
5 from .detector import Detector
L:\Anaconda2\lib\site-packages\caffe\pycaffe.py in <module>()
11 import numpy as np
12
---> 13 from ._caffe import Net, SGDSolver
14 import caffe.io
15
ImportError: DLL load failed: The specified module could not be found.
这里有什么问题?
注意事项:
我正在使用Anaconda2-2.4.1-Windows-x86_64.exe
【问题讨论】:
-
因为您手动将
caffe_root + '/python'添加到您的path我认为您不需要将模块复制到site_packages。 -
@Shai:谢谢,但是第一个链接没有什么特别之处!找不到任何信息!所以你的意思是它是多余的吗?如果是这样,为什么首先要这样声明?
标签: python-2.7 anaconda caffe jupyter-notebook pycaffe