Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 didn't work at the end of pre-training And pre-model didn't save successfully #5

Closed
chajiuqqq opened this issue May 18, 2020 · 5 comments

Comments

@chajiuqqq
Copy link

System information

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): win10 x86
TensorFlow installed from (source or binary): anaconda
TensorFlow version: 1.14.0
Python version: 3.7.4

My problem

I downloaded the data files supported by you, when I began step4.2(Keywords Extraction and Genre Pattern Building), it always showed that 'gbk' can't decode \xxx in line xx. So I tried to change the read-file way in the source. Like this:
Before:

    fin = open(file_path, 'r')

After:

    fin = open(file_path, 'r',encoding='utf-8')

It works, errors have gone when I changed all the places where it gave a decoding error.

But at the end of pre-training, it showed that "Python3 didn't work" with a dialogue box. And the code showed at last are following, And there hasn't a fold named 'premodel' in WMPoetry\wm, can you help me?

...
...
不辞朝谒远                          # 唯要近慈恩                          # 唯有信慈亲                          #
epoch: 1, 8400/8607 97.607%, 0.282 s per iter
train loss: 3.806  ppl:44.96, l2 loss: 17243.167, lr:0.0010.
______________________
今朝复相见                          # 疑是葛仙翁                          # 留是后天翁                          #
epoch: 1, 8600/8607 99.930%, 0.284 s per iter
train loss: 3.773  ppl:43.52, l2 loss: 17536.656, lr:0.0010.
______________________
0.0010 to 0.0010
run validation...
validation epoch: 1  loss: 5.679  ppl: 292.55, l2 loss: 30140.641
saving model...
WARNING:tensorflow:*******************************************************
W0518 15:41:08.506486 15588 saver.py:1134] *******************************************************
WARNING:tensorflow:TensorFlow's V1 checkpoint format has been deprecated.
W0518 15:41:08.507480 15588 saver.py:1135] TensorFlow's V1 checkpoint format has been deprecated.
WARNING:tensorflow:Consider switching to the more efficient V2 format:
W0518 15:41:08.509477 15588 saver.py:1136] Consider switching to the more efficient V2 format:
WARNING:tensorflow:   `tf.train.Saver(write_version=tf.train.SaverDef.V2)`
W0518 15:41:08.510476 15588 saver.py:1137]    `tf.train.Saver(write_version=tf.train.SaverDef.V2)`
WARNING:tensorflow:now on by default.
W0518 15:41:08.511476 15588 saver.py:1138] now on by default.
WARNING:tensorflow:*******************************************************
W0518 15:41:08.512475 15588 saver.py:1139] *******************************************************
Windows fatal exception: access violation

Current thread 0x00003ce4 (most recent call first):
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 1429 in _call_tf_sessionrun
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 1341 in _run_fn
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 1356 in _do_call
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 1350 in _do_run
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 1173 in _run
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\client\session.py", line 950 in run
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\training\saver.py", line 1173 in save
  File "pretrain.py", line 244 in train
  File "pretrain.py", line 251 in main
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\absl\app.py", line 250 in _run_main
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\absl\app.py", line 299 in run
  File "C:\Users\Alice\Miniconda3\envs\tflearning\lib\site-packages\tensorflow\python\platform\app.py", line 40 in run
  File "pretrain.py", line 254 in <module>
@XiaoyuanYi
Copy link
Owner

@chajiuqqq Hi, there should be two directories, model/ and premodel/ in WMPoetry/wm/, which are used to save checkpoints of the wm model and the pre-trained model respectively, as shown in WMPoetry/wm/config.py. Have you created these directories? Since we run our model in Linux instead of windows, there may be some unexpected problems. Please check that if you correctly create model/ and premodel/. For any further questions, just reply in this issue.

@chajiuqqq
Copy link
Author

@XiaoyuanYi Thank you for your reply, I haven't created these two directories before. And it succeeded to save model when I have done this operation. I have supposed these two directories will be created automatically.
THANK YOU!

@chajiuqqq chajiuqqq reopened this May 20, 2020
@chajiuqqq
Copy link
Author

@XiaoyuanYi I have another question when attempting to integrate WMPoetry with Flask, a framework of Python Web. If you have such experience in Python Web, hope you take a few time to view my question.

Flask receives http request and returns response after having done the designed service. It's natural to run gen_ui.py when receiving the request and finally return the output as response. But it takes time to do some same preparative work every time running gen_ui.py.

So, I'm curious if there is any way to keep gen_ui.py running and block it when hasn't request instead of restarting gen_ui.py every time.

One possible way is multi-thread. Is it possible? I'm a green hand in Python. Hope for your reply.

@XiaoyuanYi
Copy link
Owner

@chajiuqqq I would be glad to help but I'm in charge of model and algorithm design, not familiar with Flask. Sorry, I can't provide advice about this problem.

@chajiuqqq
Copy link
Author

chajiuqqq commented May 21, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants