lixin4ever / TNet

Transformation Networks for Target-Oriented Sentiment Classification (ACL 2018)
https://arxiv.org/abs/1805.01086
141 stars 31 forks source link

there is a error when run the model in long text #6

Closed BigHeartC closed 5 years ago

BigHeartC commented 5 years ago

hello, Lixin. Thanks for your code firstly. when I run TNet on a new dataset which is much longer than 14semeval and max length is 613, I met an error as below :

Traceback (most recent call last):
  File "D:/Documents/Code/Python/kaggle/paper/TNet/main.py", line 63, in <module>
    model = TNet(args=args)
  File "D:\Documents\Code\Python\kaggle\paper\TNet\layer.py", line 339, in __init__
    self.make_function()
  File "D:\Documents\Code\Python\kaggle\paper\TNet\layer.py", line 421, in make_function
    updates=self.updates,
  File "E:\Conda\lib\site-packages\theano\compile\function.py", line 326, in function
    output_keys=output_keys)
  File "E:\Conda\lib\site-packages\theano\compile\pfunc.py", line 449, in pfunc
    no_default_updates=no_default_updates)
  File "E:\Conda\lib\site-packages\theano\compile\pfunc.py", line 258, in rebuild_collect_shared
    copy_inputs_over)
  File "E:\Conda\lib\site-packages\theano\compile\pfunc.py", line 93, in clone_v_get_shared_updates
    clone_v_get_shared_updates(i, copy_inputs_over)
  File "E:\Conda\lib\site-packages\theano\compile\pfunc.py", line 93, in clone_v_get_shared_updates
    clone_v_get_shared_updates(i, copy_inputs_over)
  File "E:\Conda\lib\site-packages\theano\compile\pfunc.py", line 93, in clone_v_get_shared_updates
    clone_v_get_shared_updates(i, copy_inputs_over)
  [Previous line repeated 987 more times]
RecursionError: maximum recursion depth exceeded

I follow the advice in https://github.com/Theano/Theano/issues/689 and add code as below, but it didn't output anything for a long time.

import sys

sys.setrecursionlimit(2000)

How to fix this error in TNet when run on dataset with long text? Could you give me some advice? thx~

lixin4ever commented 5 years ago
  1. Set a larger value of recursion limit, e.g., 20000
  2. When RNN is processing the very long sequences, the BPTT is time-consuming and this is a probable reason that the program didn't output anything for a long time. May you can change BPTT to truncated BPTT and see what happen.
BigHeartC commented 5 years ago
  1. Set a larger value of recursion limit, e.g., 20000
  2. When RNN is processing the very long sequences, the BPTT is time-consuming and this is a probable reason that the program didn't output anything for a long time. May you can change BPTT to truncated BPTT and see what happen.

Thank Lixin, the first is work for me!