gpt4 book ai didi

Python 在被 caffe .prototxt 文件作为输入层调用时找不到模块

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:25 27 4
gpt4 key购买 nike

嗨,

我的输入数据序列和标签由sequence_layer.py python 文件构造。那么输入数据层为:

layer {
name: "data"
type: "Python"
top: "data"
top: "label"
top: "clip_markers"
python_param {
module: "sequence_layer"
layer: "videoReadTrain_Graylevel"
}
include: { phase: TRAIN }
}

但是,一旦我通过终端运行train.sh,python就找不到模块,错误如下:

... # perilous output are omitted here 
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc8-final"
bottom: "reshape-label"
top: "accuracy"
accuracy_param {
axis: 2
}
}
I0107 13:50:11.438953 6471 layer_factory.hpp:77] Creating layer data
Traceback (most recent call last):
File "/home/xin/caffe/sequence_layer.py", line 4, in <module>
import io
File "/usr/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: No module named _io
Done.

但是如果我在终端中输入 python 并导入模块,它工作得很好:

xin@xin-computer:~/caffe$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> import caffe
>>> import numpy
>>>

当 .prototxt 使用“print(sys.path)”调用sequence_layer.py时,我检查了PYTHONPATH。路径是正确的。

我使用的是Ubuntu 14.04LTS,caffe是用/usr/include/python2.7编译的,并且我设置了WITH_PYTHON_LAYER := 1。

谁有解决办法吗?十分感谢你的帮助。

最好,鑫

最佳答案

使用Anaconda2代替系统默认的Python2.7解决了问题。谢谢。

关于Python 在被 caffe .prototxt 文件作为输入层调用时找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41558455/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com