tech-srl / code2seq

Code for the model presented in the paper: "code2seq: Generating Sequences from Structured Representations of Code"
http://code2seq.org
MIT License
555 stars 164 forks source link

Problem with Beam Search #94

Closed noemiernst closed 3 years ago

noemiernst commented 3 years ago

Hi, whenever I put for config.BEAM_WIDTH a value > 0 in the config.py file, I end up with the following Error:

Traceback (most recent call last):
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
    return fn(*args)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.OutOfRangeError: End of sequence
         [[{{node IteratorGetNext}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/sw/installed/Python/3.6.4-golf-2018a/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 5652, in get_controller
    yield g
  File "~/code2seq/model.py", line 96, in train
    _, batch_loss = self.sess.run([optimizer, train_loss])
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run
    run_metadata_ptr)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1173, in _run
    feed_dict_tensor, options, run_metadata)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run
    run_metadata)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: End of sequence
         [[node IteratorGetNext (defined at ~/code2seq/reader.py:192) ]]

Errors may have originated from an input operation.
Input Source operations connected to node IteratorGetNext:
 IteratorV2 (defined at ~/code2seq/reader.py:190)

Original stack trace for 'IteratorGetNext':
  File "code2seq/code2seq.py", line 40, in <module>
    model.train()
  File "~/code2seq/model.py", line 77, in train
    config=self.config)
  File "~/code2seq/reader.py", line 43, in __init__
    self.output_tensors = self.compute_output()
  File "~/code2seq/reader.py", line 192, in compute_output
    return self.iterator.get_next()
  File "/.local/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 426, in get_next
    output_shapes=self._structure._flat_shapes, name=name)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_dataset_ops.py", line 1947, in iterator_get_next
    output_shapes=output_shapes, name=name)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File ".local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op
    op_def=op_def)
  File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2005, in __init__
    self._traceback = tf_stack.extract_stack()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "code2seq/code2seq.py", line 40, in <module>
    model.train()
  File "~/code2seq/model.py", line 108, in train
    results, precision, recall, f1, rouge = self.evaluate()
  File "~/code2seq/model.py", line 231, in evaluate
    hyp_path=predicted_file_name, ref_path=ref_file_name, avg=True, ignore_empty=True)
  File "/.local/lib/python3.6/site-packages/rouge/rouge.py", line 38, in get_scores
    self._check_files(hyp_path, ref_path)
  File "/.local/lib/python3.6/site-packages/rouge/rouge.py", line 28, in _check_files
    assert(hyp_lc == ref_lc)
AssertionError
urialon commented 3 years ago

Hi @noemiernst , Thank you for your interest in code2seq!

Can you try to disable rouge by changing the following two lines: https://github.com/tech-srl/code2seq/blob/master/model.py#L230-L231 to simply be rouge = 0 , and see if the problem persists?

Best, Uri

noemiernst commented 3 years ago

Hi Uri, I changed the lines and now it does not crash anymore and runs through. However the training now worsens the model with each epoch.

urialon commented 3 years ago

What exactly are you running? Please provide the exact command line, and any modifications that you made to the code or configuration.

Uri

On Sun, 2 May 2021 at 10:23 Noemi @.***> wrote:

Hi Uri, I changed the lines and now it does not crash anymore and runs through. However the training now worsens the model with each epoch.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/tech-srl/code2seq/issues/94#issuecomment-830764272, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSOXMA2JX2PBVNL5S3TCDDTLT4XFANCNFSM43WX3V6A .

noemiernst commented 3 years ago

I tried to recreate what I did and for some reason it is now doing what it should. I honestly do not know what happened but I am glad it is working now. Thanks for your help :)

urialon commented 3 years ago

Great! I'm glad to hear. Feel free to create issues if you have other questions.