尝试在tensorflow中将CRF实现为RNN时,根据此处的说明:https://github.com/liangy1969/CRF-RNN_Tensorflow,我在下面遇到了错误。
onur@onur-GE62VR-6RF:~/tf_kodlar/CRF-RNN_Tensorflow-master/src$ python3 setup.py build_ext --inplace
running build_ext
building '_permutohedral' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict
-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security
-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c
permutohedral_wrap.cxx -o build/temp.linux-x86_64-3.5/permutohedral_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for
C/ObjC but not for C++
permutohedral_wrap.cxx: In function ‘PyObject*
_wrap_PermutohedralLattice_get_enclosing_simplices(PyObject*, PyObject*)’:
permutohedral_wrap.cxx:4056:10: error: invalid conversion from ‘long long
unsigned int*’ to ‘size_t* {aka long unsigned int*}’ [-fpermissive]
arg2 = (unsigned long long*) array_data(array2);
^
permutohedral_wrap.cxx: In function ‘PyObject*
_wrap_PermutohedralLattice_get_blur(PyObject*, PyObject*)’:
permutohedral_wrap.cxx:4166:10: error: invalid conversion from ‘long long
unsigned int*’ to ‘size_t* {aka long unsigned int*}’ [-fpermissive]
arg2 = (unsigned long long*) array_data(array2);
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
在上面给出的链接中,liangy1969已经提供了permutohedral.py和_permutohedral ... pyd,但是直接尝试使用它们给出了这里的问题:https://github.com/liangy1969/CRF-RNN_Tensorflow/issues/1得出结论可能是文件的原因在win64中编译,每个都需要自己构建。但是在构建时我得到了上面的错误。
还有一个补充,在setup.py中,这个人给出了声明:include_dirs = [' $ PYTHON_PATH / Lib / site-packages / numpy / core / include']
我找不到我的python_path,或者在site-packages下找不到任何numpy / core / include但是我在/usr/local/lib/python3.5/dist-packages下找到了numpy / core / include所以我改了从site-packages到dist-packages的代码。我不知道这是不是正确的举动,不幸的是我还不是python或linux环境的专家。可能会发生我的一个非常愚蠢的错误,对不起以防万一。
我正在使用python3(3.5)和tensorflow r1.3(如果需要)和ubuntu 16.04。有人可以帮忙吗?感谢。
答案 0 :(得分:0)
我遇到了同样的问题。我删除了“长”类型说明符之一。所以不是(unsigned long long*)
而是(unsigned long*)
对于numpy路径。这是我的setup.py:
permuto_module = Extension('_permutohedral', sources = ['permutohedral_wrap.cxx', 'permutohedral.cpp'], include_dirs=['/home/hallab/.local/lib/python3.5/site-packages/numpy/core/include'])
我的numpy标头位于.local中,花了我一段时间才找到ahah。