- Python 3.6
- Pytorch 0.1.12
- CUDA 8.0
The dataset of HabeasCorpus should be existed under the folder data, which is download from ReviewNet. Then we pre-process the dataset as follows:
python3.6 prepro_gen_data.pyWe can obtain the following data:
- index2token.pkl
- token2index.pkl
- train_data.pkl
- val_data.pkl
- test_data.pkl
To train the encoder-decoder model with MLE, run
./bash_code_caption_ende_xe.shThen, we fune-tuning the network with our ARNet,
./bash_code_caption_ende_rcst.shTo test the model with greedy search, run
./bach_code_caption_ende_inf.shTo visualize the hidden states with t-SNE, run
./bash_code_caption_ende_vis.shWe will get the hidden states of generated sequence. Then, run
python3.6 prepro_tsne_reduction_vis.py --vis_batch_size 80 \
--truncation 0 \
--hidden_path '...' \
--hidden_reduction_save_path '...'We reimplement the ReviewNet proposed in Yang with PyTorch. To train the ReviewNet with MLE, run
./bash_code_caption_reviewnet_xe.shTo test the ReviewNet with greedy search, run
./bash_code_caption_reviewnet_inf.shTo train the attention-based model with MLE, run
./bash_code_caption_soft_att_xe.shTo fine-tuning the model with our ARNet based on the MLE model, run
./bash_code_caption_soft_att_rcst.shTo test the model, run
./bash_code_caption_soft_att_inf.shTo get the hidden states of the whole sequence, run
./bash_code_caption_soft_att_vis.shThen, visualize the hidden state as follows:
python3.6 prepro_tsne_reduction_vis.py --vis_batch_size 80 \
--truncation 0 \
--hidden_path '...' \
--hidden_reduction_save_path '...'