Code Monkey home page Code Monkey logo

Comments (16)

rishab-32 avatar rishab-32 commented on September 26, 2024 1

Thanks a lot, @urialon for clearing things up and sure I would use the above mentioned recommended parameters.

Best,
Rishab Sharma.

from code2seq.

rishab-32 avatar rishab-32 commented on September 26, 2024 1

Thanks, Now everything is working fine.

from code2seq.

urialon avatar urialon commented on September 26, 2024

Hi @rishab-32 ,
Is this question different than your question in #41 ?

from code2seq.

rishab-32 avatar rishab-32 commented on September 26, 2024

Hi @urialon,

Yes, it is the same I have been able to get the results for the code captioning task, thanks for your help.

However, now I am trying to get the result for code documentation. From your previous comments. What I understand is

  1. Convert Hu et al. dataset from one-large-JSON into a directory of many files (for each of training/validation/test) - Done using the following script.
    https://gist.github.com/urialon/6ce2ffab7b675d9437b730246dc07827

  2. Run preprocess.sh on the generated directories. This creates three c2s each for the train, test and valid -Done

  3. Finally, you need to "insert" the code sequences into the produced files, using this script:
    https://gist.github.com/urialon/7c4d129f6cb45c2cdba669a15f132fb4

I am confused about step 3, do I have to run the script in step 3 on the train, test, and valid directories(containing .java files and align.txt) or the c2s files generated after preprocess.sh?

And what is the next step I should follow after this?

Thanks for your help,

Best,
Rishab Sharma.

from code2seq.

urialon avatar urialon commented on September 26, 2024

Hi @rishab-32 ,

I didn't upload this pipeline officially because that dataset was problematic (if you take a look, you'll see that the NL labels contain many: " " ), and the paper's results were far from accurate.

If I remember correctly, step3 should be used here: https://github.com/tech-srl/code2seq/blob/master/preprocess.sh#L53

  • after calling the JavaExtractor, but before performing the following preprocessing and creating the c2s files.

Afterward, run the following lines: https://github.com/tech-srl/code2seq/blob/master/preprocess.sh#L58
but on the outputs of step 3 rather than the output of the JavaExtractor.

Best,
Uri

from code2seq.

rishab-32 avatar rishab-32 commented on September 26, 2024

Hi @urialon, thanks a lot for being so helpful and cooperative. Yes, you are right. Even I have seen different results being reported for the same dataset.

One last question, so the c2s files are arranged in the following form.

method_name context.

Right? where methodname acts as the target sequence while training. If I am able to replace the method_name(nonduplicates) with the natural language summary, would this be the right approach to train the model and report results, as I am using code2seq as one of the baseline to compare with my approach for the code documentation task?

from code2seq.

urialon avatar urialon commented on September 26, 2024

Sorry, I meant that many NL labels in the dataset contain: "<!-- begin-user-doc --> <!-- end-user-doc -->" as their NL documentation!

Regarding your question:
Exactly! The files that are outputted from the JavaExtractor are arranged in this form.
The c2s files are also arranged in this form, except that they are truncated if they contain too many contexts, and padded with spaces if they have too few contexts.
This truncation+padding happens in this step: https://github.com/tech-srl/code2seq/blob/master/preprocess.sh#L63

Once you manage to train a model on this dataset, I recommend using these hyperparameters that are better suited for these long documentations (the default hyperparams are optimized for short method names):

config.WORDS_MIN_COUNT = 20
config.TARGET_WORDS_MIN_COUNT = 2
config.EMBEDDINGS_SIZE = 128 * 4
config.RNN_SIZE = 128 * 4
config.DECODER_SIZE = 512
config.NUM_DECODER_LAYERS = 2

Or use the same sizes/layers as your model.

Additionally, set the max documentation length config.MAX_TARGET_PARTS similarly as your model and the other baselines. Otherwise, the model will be limited to predict only 6 words in the output.

Best,
Uri

from code2seq.

rishab-32 avatar rishab-32 commented on September 26, 2024

Hi @urialon, while I was running the train.sh, I encountered the following error. could you suggest any possible change I need to make?

tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Expect 1001 fields but have 30 in record
[[{{node IteratorGetNext}}]]
[[IteratorGetNext/_25]]
(1) Invalid argument: Expect 1001 fields but have 30 in record
[[{{node IteratorGetNext}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "code2seq.py", line 39, in
model.train()
File "/content/code2seq/model.py", line 96, in train
_, batch_loss = self.sess.run([optimizer, train_loss])
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/client/session.py", line 956, in run
run_metadata_ptr)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/client/session.py", line 1180, in _run
feed_dict_tensor, options, run_metadata)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/client/session.py", line 1359, in _do_run
run_metadata)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/client/session.py", line 1384, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Expect 1001 fields but have 30 in record
[[node IteratorGetNext (defined at /tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py:1748) ]]
[[IteratorGetNext/_25]]
(1) Invalid argument: Expect 1001 fields but have 30 in record
[[node IteratorGetNext (defined at /tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py:1748) ]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'IteratorGetNext':
File "code2seq.py", line 39, in
model.train()
File "/content/code2seq/model.py", line 77, in train
config=self.config)
File "/content/code2seq/reader.py", line 43, in init
self.output_tensors = self.compute_output()
File "/content/code2seq/reader.py", line 192, in compute_output
return self.iterator.get_next()
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/iterator_ops.py", line 426, in get_next
name=name)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/ops/gen_dataset_ops.py", line 2518, in iterator_get_next
output_shapes=output_shapes, name=name)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 1748, in init
self._traceback = tf_stack.extract_stack()

from code2seq.

urialon avatar urialon commented on September 26, 2024

Expect 1001 fields but have 30 in record

I think that didn't run the preprocess.py on the output of the scripts.

preprocess.py is supposed to pad targets that have less than 1000 contexts.

from code2seq.

DRMALEK avatar DRMALEK commented on September 26, 2024

Hi,

In step 3 and in order to insert the summary sequences instead of the method name, how I can map each method name to its summary using the data in step one and the data in step two (like from where I can get the method_id to do such matching). I'm a little confused about it.

Thanks.

-------------------- Update -----------------------
İ managed to solve the problem, by using the method names as an id to do the mapping.

from code2seq.

yingdehuijin avatar yingdehuijin commented on September 26, 2024

Hi,
i followed the 3 steps and generated the c2s files(include train test and valid).The c2s files are arranged in the following form,for example:
makes|our|egl|context|current|using|the|supplied|surface|for|both|draw|and|read|. public void makeCurrent ( EGLSurface eglSurface ) { if ( eGLDisplay == EGL14 . EGL_NO_DISPLAY ) { Log . d ( TAG , STR_ ) ; } if ( ! EGL14 . eglMakeCurrent ( eGLDisplay , eglSurface , eglSurface , eGLContext ) ) { throw new RuntimeException ( STR_ ) ; } }

is it the right form?Thanks

from code2seq.

urialon avatar urialon commented on September 26, 2024

Hi @yingdehuijin !
Thank you for your interest in our work.
Please see https://github.com/tech-srl/code2seq#extending-to-other-languages

If there are other questions, please create a new issue.
Best,
Uri

from code2seq.

yingdehuijin avatar yingdehuijin commented on September 26, 2024

Hi @yingdehuijin ! Thank you for your interest in our work. Please see https://github.com/tech-srl/code2seq#extending-to-other-languages

If there are other questions, please create a new issue. Best, Uri

Sorry for bothering you againg,after calling the JavaExtractor.It generates the raw.txt files including training/valid/test. The files are arranged in the following form:
MethodName Context
i use your first script that just creates like example_id.java files and it did not change the source code's method name . if i want to use unique id to replace MethodName ,how can i do that?

from code2seq.

urialon avatar urialon commented on September 26, 2024

I'm not sure I understand.
Why can't you just edit the file, and replace MethodName with a unique id?

from code2seq.

yingdehuijin avatar yingdehuijin commented on September 26, 2024

I'm not sure I understand. Why can't you just edit the file, and replace MethodName with a unique id?

I used Hu's the newest datasets,it contain code and nl txt files.I use your scripts https://gist.github.com/urialon/6ce2ffab7b675d9437b730246dc07827 to generate *.java files and align.txt files.But generated *.java files' methodNames are not replaced,it just changed the *.java files names. Do you mean i manually replace methodName with a unique id?

from code2seq.

urialon avatar urialon commented on September 26, 2024

If I understand correctly - yes, I think you need to make sure that the unique IDs are the same. So you can either modify them in the original raw *.java files or after preprocessing.

from code2seq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.