tech-srl / code2seq

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

A problem occurred when training started. #90

Closed AheadYoung closed 3 years ago

AheadYoung commented 3 years ago

ubuntu 18.04 python 3.6.12 tensorflow 2.3.0

First, thanks for your efforts on code2vec, code2seq and etc. I am very interested in this work, and try to learn the code details.

Followed your instruction, I have processed the “Java-small” and “py150k” two datasets. The data preprocessing is going well.

( ubuntu 18.04; python 3.6.12; tensorflow 2.3.0 )

When I run "sh train.sh", a problem occurred, which I tried to find the solution online but failed.

Here are the logging infomation, and I hope you could help me out. Thank you !

------------------------------------------

Starting training Training batch size: 128 Dataset path: data/java-small/java-small Training file path: data/java-small/java-small.train.c2s Validation path: data/java-small/java-small.val.c2s Taking max contexts from each example: 100 Random path sampling: True Embedding size: 128 Using BiLSTMs, each of size: 128 Decoder size: 320 Decoder layers: 1 Max path lengths: 9 Max subtokens in a token: 5 Max target length: 6 Embeddings dropout keep_prob: 0.75 LSTM dropout keep_prob: 0.5

2021-04-19 20:38:03.341923: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them. Number of trainable params: 10950144 Start training loop... 0%| | 0/691974 [00:00<?, ?it/s]2021-04-19 20:38:10.944279: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 Traceback (most recent call last): File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 338, in _flatten_module leaves = nest.flatten_with_tuple_paths(prop) File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 1400, in flatten_with_tuple_paths flatten(structure, expand_composites=expand_composites))) File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 338, in flatten return _pywrap_utils.Flatten(structure, expand_composites) TypeError: '<' not supported between instances of 'WhileBodyFuncGraph' and 'FuncGraph'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/yangkang/container_data/Code/code2seq/code2seq.py", line 35, in model.train() File "/home/yangkang/container_data/Code/code2seq/modelrunner.py", line 129, in train gradients = tape.gradient(loss, self.model.trainable_variables) File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 169, in trainable_variables return tuple(self._flatten(predicate=_is_trainable_variable)) File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 376, in _flatten_module for subvalue in subvalues: File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 376, in _flatten_module for subvalue in subvalues: File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 376, in _flatten_module for subvalue in subvalues: File "/home/yangkang/anaconda3/envs/tf21-gpu/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 343, in _flatten_module cause) File "", line 3, in raise_from ValueError: Error processing property '_dropout_mask_cache' of <ContextValueCache at 0x7f3ede4b7f98> 0%| | 0/691974 [00:08<?, ?it/s]

Process finished with exit code 1

urialon commented 3 years ago

Hi @AheadYoung , Thank you for your interest in our work!

This looks like you are not using our version of code2seq. For example, your version has a file modelrunner.py which does not exist in this repository.

Best, Uri

AheadYoung commented 3 years ago

I followed @Kolkir: https://github.com/Kolkir/code2seq, which inplemnet in tf 2.1. I clone the code in your repository and it works fine.

Thank you for your immediate reply and sorry for disturbing.

Best, AheadYoung

urialon commented 3 years ago

Does @Kolkir 's code work for you if you use TF 2.1 instead of your current version?

I can help only if it's my code, which uses TF 1.12.

AheadYoung commented 3 years ago

@Kolkir 's code didn't work directly. The data preprocessing part is working.

I met some Errors in the training process, including "ImportError", and the one I reported above.

If I fixed the problem in his code, I will let you know.

AheadYoung commented 3 years ago

Does @Kolkir 's code work for you if you use TF 2.1 instead of your current version?

I can help only if it's my code, which uses TF 1.12.

Finally, @Kolkir 's code is working. His code is a good implement.

The main problem is blame on myself. I made the mistake that incompatibility issues between TensorFlow 2.1, and tensorflow-addons. When I change the version of tensorflow-addons, it goes well.

TensorFlow Addons TensorFlow Python
tfa-nightly 2.3, 2.4 3.6, 3.7, 3.8
tensorflow-addons-0.12.1 2.3, 2.4 3.6, 3.7, 3.8
tensorflow-addons-0.11.2 2.2, 2.3 3.5, 3.6, 3.7, 3.8
tensorflow-addons-0.10.0 2.2 3.5, 3.6, 3.7, 3.8
tensorflow-addons-0.9.1 2.1, 2.2 3.5, 3.6, 3.7
tensorflow-addons-0.8.3 2.1 3.5, 3.6, 3.7
tensorflow-addons-0.7.1 2.1 2.7, 3.5, 3.6, 3.7
tensorflow-addons-0.6.0 2.0 2.7, 3.5, 3.6, 3.7

Best, AheadYoung

urialon commented 3 years ago

Great! I'm glad to hear!

AheadYoung commented 3 years ago

Great! I'm glad to hear! Thank you for your time.