{"action":"created","issue":{"url":"https://api.github.com/repos/minsangkim142/R-net/issues/15","repository_url":"https://api.github.com/repos/minsangkim142/R-net","labels_url":"https://api.github.com/repos/minsangkim142/R-net/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/minsangkim142/R-net/issues/15/comments","events_url":"https://api.github.com/repos/minsangkim142/R-net/issues/15/events","html_url":"https://github.com/minsangkim142/R-net/issues/15","id":267441822,"number":15,"title":"Weird error message when run `python model.py`.","user":{"login":"yangyuan","id":6030719,"avatar_url":"https://avatars3.githubusercontent.com/u/6030719?v=4","gravatar_id":"","url":"https://api.github.com/users/yangyuan","html_url":"https://github.com/yangyuan","followers_url":"https://api.github.com/users/yangyuan/followers","following_url":"https://api.github.com/users/yangyuan/following{/other_user}","gists_url":"https://api.github.com/users/yangyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/yangyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yangyuan/subscriptions","organizations_url":"https://api.github.com/users/yangyuan/orgs","repos_url":"https://api.github.com/users/yangyuan/repos","events_url":"https://api.github.com/users/yangyuan/events{/privacy}","received_events_url":"https://api.github.com/users/yangyuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-10-22T07:04:06Z","updated_at":"2017-11-04T00:33:42Z","closed_at":null,"author_association":"NONE","body":"I tried to run this project in a totally new environment. (Ubuntu 16.04 64 bit, Python 2.7)\r\nI strictly followed the instructions. However, I always end with an error message (see below) when I run `python model.py`.\r\n\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"model.py\", line 258, in <module>\r\n    main()\r\n  File \"model.py\", line 231, in main\r\n    sess.run(model.train_op)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py\", line 789, in run\r\n    run_metadata_ptr)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py\", line 997, in _run\r\n    feed_dict_string, options, run_metadata)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py\", line 1132, in _do_run\r\n    target_list, options, run_metadata)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py\", line 1152, in _do_call\r\n    raise type(e)(node_def, op, message)\r\ntensorflow.python.framework.errors_impl.InvalidArgumentError: seq_lens(8218) > input.dims(1)\r\n         [[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)]]\r\n\r\nCaused by op u'passage_char_encoding/bidirectional_rnn/bw/ReverseSequence', defined at:\r\n  File \"model.py\", line 258, in <module>\r\n    main()\r\n  File \"model.py\", line 209, in main\r\n    model = Model(is_training = True); print(\"Built model\")\r\n  File \"model.py\", line 43, in __init__\r\n    self.encode_ids()\r\n  File \"model.py\", line 81, in encode_ids\r\n    is_training = self.is_training)\r\n  File \"/root/nlp/R-net/layers.py\", line 98, in bidirectional_GRU\r\n    dtype=tf.float32)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py\", line 396, in bidirectional_dynamic_rnn\r\n    seq_dim=time_dim, batch_dim=batch_dim)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py\", line 389, in _reverse\r\n    seq_dim=seq_dim, batch_dim=batch_dim)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py\", line 2355, in reverse_sequence\r\n    name=name)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py\", line 2633, in reverse_sequence\r\n    batch_dim=batch_dim, name=name)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py\", line 767, in apply_op\r\n    op_def=op_def)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py\", line 2506, in create_op\r\n    original_op=self._default_original_op, op_def=op_def)\r\n  File \"/root/nlp/venv/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py\", line 1269, in __init__\r\n    self._traceback = _extract_stack()\r\n\r\nInvalidArgumentError (see above for traceback): seq_lens(8218) > input.dims(1)\r\n         [[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)]]\r\n```\r\n\r\nAny idea about this problem?\r\n\r\nI'm using the current code without any modification.\r\n\r\nThis this the pip packages I installed.\r\nnltk==3.2.4\r\nnumpy==1.13.1\r\nscikit-learn==0.19.0\r\nscipy==0.19.1\r\nspacy==1.9.0\r\ntensorflow==1.2.0\r\ntensorflow-tensorboard==0.1.8\r\ntqdm==4.15.0"},"comment":{"url":"https://api.github.com/repos/minsangkim142/R-net/issues/comments/341858260","html_url":"https://github.com/minsangkim142/R-net/issues/15#issuecomment-341858260","issue_url":"https://api.github.com/repos/minsangkim142/R-net/issues/15","id":341858260,"user":{"login":"huangpeng1126","id":1445247,"avatar_url":"https://avatars2.githubusercontent.com/u/1445247?v=4","gravatar_id":"","url":"https://api.github.com/users/huangpeng1126","html_url":"https://github.com/huangpeng1126","followers_url":"https://api.github.com/users/huangpeng1126/followers","following_url":"https://api.github.com/users/huangpeng1126/following{/other_user}","gists_url":"https://api.github.com/users/huangpeng1126/gists{/gist_id}","starred_url":"https://api.github.com/users/huangpeng1126/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huangpeng1126/subscriptions","organizations_url":"https://api.github.com/users/huangpeng1126/orgs","repos_url":"https://api.github.com/users/huangpeng1126/repos","events_url":"https://api.github.com/users/huangpeng1126/events{/privacy}","received_events_url":"https://api.github.com/users/huangpeng1126/received_events","type":"User","site_admin":false},"created_at":"2017-11-04T00:33:42Z","updated_at":"2017-11-04T00:33:42Z","author_association":"NONE","body":"@minsangkim142 , I have 2 modification:\r\n\r\n1.  define a new function in 'process.py':\r\n```python\r\ndef pad_char_len(data, max_word, max_char):\r\n    padded_data = np.zeros((len(data), max_word), dtype=np.int32)\r\n    for i, line in enumerate(data):\r\n        for j, word in enumerate(line):\r\n            if j >= max_word:\r\n                break\r\n            padded_data[i, j] = word if word <= max_char else max_char\r\n    return padded_data\r\n```\r\n2. File 'data_load.py' in line 143~147 change to the following:\r\n```python\r\n# to numpy\r\n    indices = np.reshape(np.asarray(indices, np.int32), (-1, 2))\r\n    p_word_len = np.reshape(np.asarray(p_word_len, np.int32), (-1, 1))\r\n    q_word_len = np.reshape(np.asarray(q_word_len, np.int32), (-1, 1))\r\n    # p_char_len = pad_data(p_char_len, p_max_word)\r\n    # q_char_len = pad_data(q_char_len, q_max_word)\r\n    p_char_len = pad_char_len(p_char_len, p_max_word, p_max_char)\r\n    q_char_len = pad_char_len(q_char_len, q_max_word, q_max_char)\r\n    # fix p(q)_word_len\r\n    for i in range(p_word_len.shape[0]):\r\n        if p_word_len[i,0] > p_max_word:\r\n            p_word_len[i,0] = p_max_word\r\n    for i in range(q_word_len.shape[0]):\r\n        if q_word_len[i,0] > q_max_word:\r\n            q_word_len[i,0] = q_max_word\r\n```\r\n"}}
{"actor":{"display_login":"huangpeng1126"}}