构建CRF-RNN张量流实现

问题描述 投票:1回答:1

尝试在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 = ['$ P​​YTHON_PATH / Lib / site-packages / numpy / core / include']

我找不到我的python_path,或者在site-packages下找不到任何numpy / core / include但是我在/usr/local/lib/python3.5/dist-packages下找到了numpy / core / include,所以我改变了网站的代码 - 包装到dist-packages。我不知道这是不是一个正确的举动,不幸的是我还不是python或linux环境的专家。可能会发生我的一个非常愚蠢的错误,对不起以防万一。

我正在使用python3(3.5)和tensorflow r1.3(如果需要)和ubuntu 16.04。有人可以帮忙吗?谢谢。

python-3.x tensorflow ubuntu-16.04 rnn crf
1个回答
0
投票

我遇到了同样的问题。我删除了一个'long'类型说明符。因此,而不是(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。

© www.soinside.com 2019 - 2024. All rights reserved.