attention
attention copied to clipboard
ModuleNotFoundError: No module named 'attention'
sudo apt install python-pip
pip install tensorflow
pip install dm-sonnet
pip install tqdm
pip install numpy
git clone https://github.com/louishenrifranc/attention.git
cd attention
./run_micro_services.sh
Gives:
$ ./run_micro_services.sh
Experiment will be run without saving current version of the code/config
Running Task Data Generation
Traceback (most recent call last):
File "attention/services/create_copy_task/create_copy_task.py", line 1, in <module>
from tqdm import trange
ModuleNotFoundError: No module named 'tqdm'
Run Task Data Generation
Run Attention Traininig
Traceback (most recent call last):
File "attention/services/attention_train/attentiontrain.py", line 6, in <module>
from attention.utils.config import AttrDict, RunConfig
ModuleNotFoundError: No module named 'attention'
So tried:
sudo apt install python3-tqdm
sudo apt install python3-numpy
But then get:
$ ./run_micro_services.sh
Experiment will be run without saving current version of the code/config
Running Task Data Generation
Traceback (most recent call last):
File "attention/services/create_copy_task/create_copy_task.py", line 9, in <module>
from attention.utils.config import AttrDict
ModuleNotFoundError: No module named 'attention'
Run Task Data Generation
Run Attention Traininig
Traceback (most recent call last):
File "attention/services/attention_train/attentiontrain.py", line 6, in <module>
from attention.utils.config import AttrDict, RunConfig
ModuleNotFoundError: No module named 'attention'
OS: Ubuntu Bionic. Any ideas?
cp attention/utils/config.py ./attention/services/create_copy_task/
cp attention/utils/config.py ./attention/services/attention_train/
and change attention/services/create_copy_task/create_copy_task.py to:
from config import AttrDict
and similar change to attention/services/attention_train/attentiontrain.py and similar copy/change for other things reference from top of attentiontrain.py etc. It may end up working that way, but it's hacky.
Found a solution here (the problem is python 3 compatibility): https://stackoverflow.com/questions/45415473/importing-module-from-sub-directory-works-in-python-2-but-not-python-3
Patch that will fix this;
# git diff
diff --git a/run_micro_services.sh b/run_micro_services.sh
old mode 100644
new mode 100755
index 26a615d..96ab557
--- a/run_micro_services.sh
+++ b/run_micro_services.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+export PYTHONPATH=${PWD}
+
OUTPUT_DIR="transformer_output"
TASK_CONFIG="attention/services/create_copy_task/default_config.json"
METADATA="attention/services/attention_train/default_metadata.json"