DeepBrainAI / ERD

24 stars 15 forks source link

local variable 't_words' referenced before assignment #2

Open HaozhengLi opened 5 years ago

HaozhengLi commented 5 years ago

I use the Twitter_DataSet to train.

I successfully train a df_model but get errors while training a rl_model.

2019-06-19 21:55:53 Loading data ...
2 data loaded
2019-06-19 21:56:52 Data loaded.
2019-06-19 21:56:52.885374: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
300 100 100 100 2 2
df_saved\model is restored.
in RL the begining
2019-06-19 21:56:53 Now Start RL training ...
0 0
Traceback (most recent call last):
  File "main.py", line 165, in <module>
    rl_train(sess, mm, 0.5, 50000)
  File "main.py", line 84, in rl_train
    x, y, ids, seq_states, max_id = get_rl_batch(ids, seq_states, isStop, max_id, 0, 3150)
  File "E:\Output\Python_output\ERD\ERD\dataUtils.py", line 187, in get_rl_batch
    try:
UnboundLocalError: local variable 't_words' referenced before assignment

Here's my question, in line 181 we try to get . But if we fail, there will not be a reachable , then errors occur.

        else:
            try:
                t_words = data[ids[i]]['text'][seq_states[i]].strip().split(" ")
            except:
                print(ids[i],seq_states[i])
            for j in range(len(t_words)):
                m_word = t_words[j]
                try:
                    input_x[i][j] = word2vec[m_word]
                except:
                    miss_vec = 1
            input_y[i] = data_y[ids[i]]

So how can I run the code correctly?

Thank you.

DeepBrainAI commented 4 years ago

New Code Updared.

shaodiandian123 commented 4 years ago

Hi I met the same problem, did you solve it? Thank you.

DeepBrainAI commented 4 years ago

https://github.com/DeepBrainAI/ERD/tree/master/torch

try the torch code     ------------------ Original ------------------ From: "shaodiandian123"; Date: 2020年4月3日(星期五) 下午2:16 To: "DeepBrainAI/ERD"; Cc: "DeepBrainAI"; "Comment"; Subject: Re: [DeepBrainAI/ERD] local variable 't_words' referenced before assignment (#2)

 

Hi I met the same problem, did you solve it? Thank you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.