Comments (7)
My understanding of the extraction step is that I specify the target as say, the method name or a caption and in the list of contexts, I can specify any type of component suitable for my problem
That's right! There are several things to notice:
- The words in
target
should be split by|
, i.e.:print|bmp|to|file
- The 3-tuple
type_of_statement|token_1|token_2
should be split by comma (,
) rather than|
, and each of them internally should be split by|
. - The network reads the 1st and 3rd fields as a set of subtokens, and the 2nd field as a sequence (using an LSTM). So I would suggest switch the order and make
type_of_statement
to be the middle field, and setconfig.MAX_PATH_LENGTH = 1
. So finally it will look like:
print|bmp|to|file subtoken1|subtoken2|subtoken3,type_of_statement,subtoken4|subtoken5|subtoken6
Where subtoken1|subtoken2|subtoken3
are the components of token_1
in your example,
and subtoken4|subtoken5|subtoken6
are the components of token_2
from your example.
Since type_of_statement
is a single value (rather than a sequence of symbols you can set config.MAX_PATH_LENGTH = 1
and training will be faster because the LSTM will not be used.
from code2seq.
basically yes, see also Section 2 of the code2vec paper, where it is explained more thoroughly:
https://arxiv.org/abs/1803.09473
from code2seq.
On a related note, could you please explain the role of config.MAX_PATH_LENGTH
in a bit more detail? I am not familiar with the model, so still trying to figure out this error, which seems to be related to this constant.
from code2seq.
Hi Pankaj,
Did you run the model on a dataset that you preprocessed yourself, i.e., not our preprocessed dataset? Did you preprocess your dataset with a non-default max_path_length value? Or did you decrease the default value in config.MAX_PATH_LENGTH
?
In general, config.MAX_PATH_LENGTH
in the model should be greater by 1
than the max_path_length
value of the preprocessing. This is indeed confusing.
config.MAX_PATH_LENGTH
is the number of nodes in each "path".
For legacy reasons, in the JavaExtractor, the max_path_length is the number of edges and is set to 8
by default. This is the reasons that the default value for config.MAX_PATH_LENGTH
is: 8+1
.
from code2seq.
Hello, thank you for the response!
Yes, I'm using another dataset for which I wrote another extractor, and then I ran preprocess.sh
on just the extracted result (i.e. my self created train.raw.txt
, val.raw.txt
, test.raw.txt
). I guess my mistake is that I did not take into account the max_path_length
property in my extraction code.
My understanding of the extraction step is that I specify the target as say, the method name or a caption and in the list of contexts, I can specify any type of component suitable for my problem. My extracted rows deal with code lines individually and are of the form target type_of_statement|token_1|token_2 ...
, where type_of_statement is chosen from a set of 25 possible values indicating the type of code statement and tokens are similar to your example.
So just to clarify, how would you suggest me to account for max_path_length
in my extraction code?
from code2seq.
Thank you for your help, this clarified a lot!! :)
from code2seq.
Btw, wanted to seek understanding on your usage of Abstract Syntax Tree in extraction step. Quoting from the paper:
Given the AST of a code snippet, we consider all pairwise paths between terminals, and represent them as sequences of terminal and nonterminal nodes. We then use these paths with their terminals’ values to represent the code snippet itself.
Does this mean that given the AST, you are extracting all possible terminal-to-terminal paths from the tree and extracting contexts in the form terminal node token, path of intermediate non-terminal nodes, terminal node token
?
from code2seq.
Related Issues (20)
- Generating embeddings for Python and Java HOT 5
- Help with implementing local service with JavaExtractor HOT 10
- I can not preprocess Python dataset
- Error running prediction on Code2seq released model
- I got Out of Memory Error during Training
- Unable to get embeddings from the trained model for Java
- Extract Path Contexts Only HOT 5
- InvalidArgumentError in sess.run() HOT 3
- Visualize Python AST HOT 2
- Extract java files HOT 2
- Getting "was not completed in time" error when preprocessing dataset HOT 11
- code2seq for Python HOT 3
- Error processing property '_dropout_mask_cache' of <ContextValueCache> HOT 6
- Sampling k paths from AST tree HOT 11
- I am getting TimeError while using code2seq to predict long method HOT 2
- Generating code documentation with code2seq HOT 8
- Tensorflow out-of-bound error while trying to train the Code2Seq model on our own python dataset HOT 6
- Model is predicting empty string for custom python dataset HOT 8
- Exporting code vectors HOT 6
- Encountered error of preprocess data HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code2seq.