question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird error message when run `python model.py`.

See original GitHub issue

I tried to run this project in a totally new environment. (Ubuntu 16.04 64 bit, Python 2.7) I strictly followed the instructions. However, I always end with an error message (see below) when I run python model.py.

Traceback (most recent call last):
  File "model.py", line 258, in <module>
    main()
  File "model.py", line 231, in main
    sess.run(model.train_op)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 789, in run
    run_metadata_ptr)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 997, in _run
    feed_dict_string, options, run_metadata)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1132, in _do_run
    target_list, options, run_metadata)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1152, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: seq_lens(8218) > input.dims(1)
         [[Node: passage_char_encoding/bidirectional_rnn/bw/ReverseSequence = ReverseSequence[T=DT_FLOAT, Tlen=DT_INT32, batch_dim=0, seq_dim=1, _device="/job:localhost/replica:0/task:0/cpu:0"](passage_char_encoding/Reshape, passage_char_encoding/Reshape_1)]]

Caused by op u'passage_char_encoding/bidirectional_rnn/bw/ReverseSequence', defined at:
  File "model.py", line 258, in <module>
    main()
  File "model.py", line 209, in main
    model = Model(is_training = True); print("Built model")
  File "model.py", line 43, in __init__
    self.encode_ids()
  File "model.py", line 81, in encode_ids
    is_training = self.is_training)
  File "/root/nlp/R-net/layers.py", line 98, in bidirectional_GRU
    dtype=tf.float32)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 396, in bidirectional_dynamic_rnn
    seq_dim=time_dim, batch_dim=batch_dim)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 389, in _reverse
    seq_dim=seq_dim, batch_dim=batch_dim)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 2355, in reverse_sequence
    name=name)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2633, in reverse_sequence
    batch_dim=batch_dim, name=name)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): seq_lens(8218) > input.dims(1)
         [[Node: passage_char_encoding/bidirectional_rnn/bw/ReverseSequence = ReverseSequence[T=DT_FLOAT, Tlen=DT_INT32, batch_dim=0, seq_dim=1, _device="/job:localhost/replica:0/task:0/cpu:0"](passage_char_encoding/Reshape, passage_char_encoding/Reshape_1)]]

Any idea about this problem?

I’m using the current code without any modification.

This this the pip packages I installed. nltk==3.2.4 numpy==1.13.1 scikit-learn==0.19.0 scipy==0.19.1 spacy==1.9.0 tensorflow==1.2.0 tensorflow-tensorboard==0.1.8 tqdm==4.15.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16

github_iconTop GitHub Comments

3reactions
huangpeng1126commented, Nov 4, 2017

@minsangkim142 , I have 2 modification:

  1. define a new function in ‘process.py’:
def pad_char_len(data, max_word, max_char):
    padded_data = np.zeros((len(data), max_word), dtype=np.int32)
    for i, line in enumerate(data):
        for j, word in enumerate(line):
            if j >= max_word:
                break
            padded_data[i, j] = word if word <= max_char else max_char
    return padded_data
  1. File ‘data_load.py’ in line 143~147 change to the following:
# to numpy
    indices = np.reshape(np.asarray(indices, np.int32), (-1, 2))
    p_word_len = np.reshape(np.asarray(p_word_len, np.int32), (-1, 1))
    q_word_len = np.reshape(np.asarray(q_word_len, np.int32), (-1, 1))
    # p_char_len = pad_data(p_char_len, p_max_word)
    # q_char_len = pad_data(q_char_len, q_max_word)
    p_char_len = pad_char_len(p_char_len, p_max_word, p_max_char)
    q_char_len = pad_char_len(q_char_len, q_max_word, q_max_char)
    # fix p(q)_word_len
    for i in range(p_word_len.shape[0]):
        if p_word_len[i,0] > p_max_word:
            p_word_len[i,0] = p_max_word
    for i in range(q_word_len.shape[0]):
        if q_word_len[i,0] > q_max_word:
            q_word_len[i,0] = q_max_word
1reaction
Levstylecommented, Oct 24, 2017

@thisum I have not figured out how the point network works! So i do not know how to fix it! I need more time to figure out the shape of every tensor!.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Weird error message when run python model.py . #15 - GitHub
I tried to run this project in a totally new environment. (Ubuntu 16.04 64 bit, Python 2.7) I strictly followed the instructions.
Read more >
I get strange error when running a python script - Stack Overflow
I tried to run the script by doing python answer_bot.py. and I get this error. Traceback (most recent call last): File "answer_bot.py", ...
Read more >
Syntax Error in Python 3.10 when running on Terminal
Hey guys, I'm new to Python & I tried to run my 1st Python script (“Hello World”) on the terminal using Python 3.10....
Read more >
A few weird errors - v4 - PyMC Discourse
When I'm fitting models on Jupiter notebook (through vs code on mac), no matter how many cores I use, it runs fine. But...
Read more >
What to do when you get an error - Hugging Face Course
Debugging the pipeline from Transformers · The error messages in Python are known as tracebacks and are read from bottom to top. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found