This is the code repository of the abductive learning framework for handwritten equation decipherment experiments in Bridging Machine Learning and Logical Reasoning by Abductive Learning in NeurIPS 2019.
This code is only tested in Linux environment.
- Swi-Prolog
- Python3 with Numpy, Tensorflow and Keras
- ZOOpt (as a submodule)
http://www.swi-prolog.org/build/unix.html
linux: you can use these code to install swi-prolog
% sudo apt-get install software-properties-common
% sudo apt-add-repository ppa:swi-prolog/stable
% sudo apt-get update
% sudo apt-get install swi-prolog
and then
whereis swi-prolog
my path is /usr/lib/swi-prolog this path is your prolog root dir
https://wiki.python.org/moin/BeginnersGuide/Download
#install numpy tensorflow keras pillow
pip3 install numpy
pip3 install tensorflow
pip3 install keras
pip3 install zoopt
pip3 install pillow
Set environment variables(Should change file path according to your situation)
# cd to ABL-HED
git submodule update --init --recursive
export ABL_HOME=$PWD
cp /usr/lib/swi-prolog/lib/x86_64-linux/libswipl.so $ABL_HOME/src/logic/lib/
cp /usr/lib/swi-prolog/lib/x86_64-linux/libswipl.so.8 $ABL_HOME/src/logic/lib/
export LD_LIBRARY_PATH=$ABL_HOME/src/logic/lib
export SWI_HOME_DIR=/usr/lib/swi-prolog/
# for GPU user
export LD_LIBRARY_PATH=$ABL_HOME/src/logic/lib:/usr/local/cuda:$LD_LIBRARY_PATH
First change the swipl_include_dir
and swipl_lib_dir
in setup.py
to your own SWI-Prolog path.
swipl_include_dir = '/usr/lib/swi-prolog/include'
swipl_lib_dir = '/usr/lib/swi-prolog/lib/x86_64-linux'
and then
cd src/logic/prolog
python3 setup.py install
Change directory to ABL-HED
, and run equaiton generator to get the training data
cd src/
python3 equation_generator.py
Run abductive learning code
cd src/
python3 main.py
or
python3 main.py --help
To test the RBA example, please specify the src_data_name
and src_data_file
together, e.g.,
python main.py --src_data_name random_images --src_data_file random_equation_data_train_len_26_test_len_26_sys_2_.pk
- Wang-Zhou Dai (Imperial College London)
- Yu-Xuan Huang (Nanjing University)
- Le-Wen Cai (Nanjing University)