源碼:https://github.com/thu-media/Comyco
1. 運行rl_test.py
創(chuàng)建python版本為3.6的anaconda環(huán)境蔼两,命名為comyco
conda create -n comyco python=3.6
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy tensorflow==1.12.0 tflearn sklearn
注:tflearn不能在tensorflow2.0下使用,所以要限制tensorflow的版本為1.12.0.
按照下面的命令安裝swig時出現(xiàn)錯誤吐葵。
pip install swig
ERROR: Could not find a version that satisfies the requirement swig (from versions: none)
ERROR: No matching distribution found for swig
按照下面命令用conda安裝swig
conda install swig
pip install pydotplus
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple statsmodels
2. 運行train.py
(1) 安裝swig
https://www.dev2qa.com/how-to-install-swig-on-macos-linux-and-windows/
出現(xiàn)問題:
swig: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
按照如下鏈接安裝pcre-8.43后拷貝libpcre.so.1到/usr/lib/后能夠運行:
https://blog.csdn.net/will199321/article/details/87920904
https://unix.stackexchange.com/questions/421257/swig-error-in-ubuntu-16-04
xcc:~/download/pcre-8.43/.libs$ swig -version
SWIG Version 4.0.1
Compiled with g++ [x86_64-pc-linux-gnu]
Configured options: +pcre
Please see http://www.swig.org for reporting bugs and further information
(2) 生成_envcpp.so
使用linux環(huán)境下的代碼污筷。
swig -c++ -python abr.i
g++ abr_wrap.cxx env.cpp -fPIC -shared -I /home/xcc/anaconda2/envs/comyco/include -I /home/xcc/anaconda2/envs/comyco/include/python3.6m -L /home/xcc/anaconda2/envs/comyco/lib -o _envcpp.so -O4
然后把生成的envcpp.py
和_envcpp.so
拷貝到/Comyco/src/文件夾下工闺,就可以運行train.py了。
相關(guān)鏈接:
https://stackoverflow.com/questions/4095083/swig-no-module-named-example
http://www.swig.org/Doc1.3/Python.html#Python_nn72
http://www.swig.org/papers/PyTutorial98/PyTutorial98.pdf