thaije / code-to-comment Goto Github PK
View Code? Open in Web Editor NEWSet of (Tensorflow) implementations which generate comments from code. Thesis for the B.sc. AI.
Set of (Tensorflow) implementations which generate comments from code. Thesis for the B.sc. AI.
Thanks for thaije sharing the codes online. I learned a lot from this.
Here is my question.
I trained a model by function train() first.
Then call function evaluate() to translate sentences in 10pt.random.code
I got the following error.
File "/Users/yy/PycharmProjects/code_to_comment/seq2seq/translate.py", line 434, in <module> tf.app.run() File "/anaconda/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run sys.exit(main(sys.argv)) File "/Users/yy/PycharmProjects/code_to_comment/seq2seq/translate.py", line 429, in main evaluate() File "/Users/yy/PycharmProjects/code_to_comment/seq2seq/translate.py", line 347, in evaluate translate_file() File "/Users/yy/PycharmProjects/code_to_comment/seq2seq/translate.py", line 198, in translate_file translated_file.write(" ".join([tf.compat.as_str(rev_en_vocab[output]) for output in outputs]) + "\n") IndexError: list index out of range
rev_en_vocab is a list that generated from the file "vocab100000.code", which only contains 21298 elements. However the element in outputs (len(output)=50) is 80000+. which leads to the "list out of range error".
Is there something wrong with the vocab100000.code ?
Or is there something wrong with the output variable ?
Anyone can help me please?
Thanks!
( Mac os 10.11, python 2.7, tensorflow 0.11.0)
`Preparing data in ./data/django/
Creating 2 layers of 512 units.
Reading model parameters from ./train/translate.ckpt-40
Reading development and training data (limit: 0).
Traceback (most recent call last):
File "translate.py", line 443, in
tf.app.run()
File "/anaconda/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv))
File "translate.py", line 440, in main
train()
File "translate.py", line 290, in train
evaluate()
File "translate.py", line 352, in evaluate
translate_file()
File "translate.py", line 149, in translate_file
model = create_model(sess, False)
File "translate.py", line 225, in create_model
forward_only=forward_only)
File "/Users/yy/PycharmProjects/test_code2comment/seq2seq/seq2seq_model.py", line 89, in init
w = tf.get_variable("proj_w", [size, self.target_vocab_size])
File "/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 339, in get_variable
collections=collections)
File "/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 262, in get_variable
collections=collections, caching_device=caching_device)
File "/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 118, in get_variable
name, "".join(traceback.format_list(tb))))
ValueError: Variable proj_w already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
File "/Users/yy/PycharmProjects/test_code2comment/seq2seq/seq2seq_model.py", line 89, in init
w = tf.get_variable("proj_w", [size, self.target_vocab_size])
File "translate.py", line 225, in create_model
forward_only=forward_only)
File "translate.py", line 248, in train
model = create_model(sess, False)`
Anyone know how to solve the problem?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.