Skip to content
Repository for the code of the "A Convolutional Attention Network for Extreme Summarization of Source Code" paper
HTML Python
Branch: master
Clone or download

Latest commit

mallamanis Merge pull request #1 from udibr/master
fix code to work with theano 0.9
Latest commit a271856 Jul 19, 2016

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
analysis Initial commit. Migration from messy repository. May 7, 2016
convolutional_attention save result every time a new best is reached, max_num_epochs=0 perfor… Jul 18, 2016
theanoutils cast to floatX Jul 18, 2016
.gitignore Initial commit. Migration from messy repository. May 7, 2016
LICENSE Initial commit. Migration from messy repository. May 7, 2016
README.md type Jul 18, 2016

README.md

Convolutional Attention Network

Code related to the paper:

@inproceedings{allamanis2016convolutional,
  title={A Convolutional Attention Network for Extreme Summarization of Source Code},
  author={Allamanis, Miltiadis and Peng, Hao and Sutton, Charles},
  booktitle={International Conference on Machine Learning (ICML)},
  year={2016}
}

For more information and the data of the paper, see here.

The project depends on Theano and uses Python 2.7.

Usage Instructions

To train the copy_attention model with the data use

> python copy_conv_rec_learner.py <training_file> <max_num_epochs> <D> <test_file>

were D is the embedding space dimenssion (128 in paper.) The best model will be saved at <training_file>.pkl

To evaluate an existing model re-run with exactly the same parameteres except for <max_num_epochs> which should be zero.

The following code will generate names from a pre-trained model and a test_file with code examples.

model = ConvolutionalCopyAttentionalRecurrentLearner.load(model_fname)
test_data, original_names = model.naming_data.get_data_in_recurrent_copy_convolution_format(test_file, model.padding_size)
test_name_targets, test_code_sentences, test_code, test_target_is_unk, test_copy_vectors = test_data

idx = 2  # pick an example from test_file
res = model.predict_name(np.atleast_2d(test_code[idx]))
print "original name:", ' '.join(original_names[idx].split(','))
print "code:", ' '.join(test_code[idx])
print "generated names:"
for r,v in res:
    print v, ' '.join(r)
You can’t perform that action at this time.