stanfordnlp/cocoa

IndexError: too many indices for array

CSSE-NULL opened this issue · 3 comments

When I try to chat with the bot in the web interface, I got the error below:

Traceback (most recent call last):
  File "/home/.local/lib/python2.7/site-packages/gevent/pywsgi.py", line 976, in handle_one_response
    self.run_application()
  File "/home/.local/lib/python2.7/site-packages/gevent/pywsgi.py", line 923, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/.local/lib/python2.7/site-packages/flask_socketio/__init__.py", line 42, in __call__
    start_response)
  File "/home/.local/lib/python2.7/site-packages/engineio/middleware.py", line 67, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/cocoa/cocoa/web/views/chat.py", line 48, in check_inbox
    event = backend.receive(uid)
  File "/home/cocoa/cocoa/web/main/backend.py", line 838, in receive
    controller.step(self)
  File "/home/cocoa/cocoa/core/controller.py", line 109, in step
    event = session.send()
  File "/home/cocoa/cocoa/sessions/timed_session.py", line 60, in send
    self.queued_event.append(self.session.send())
  File "/home/cocoa/craigslistbargain/sessions/neural_session.py", line 64, in send
    tokens = self.generate()
  File "/home/cocoa/craigslistbargain/sessions/neural_session.py", line 158, in generate
    output_data = self.generator.generate_batch(batch, gt_prefix=self.gt_prefix, enc_state=enc_state)
  File "/home/cocoa/cocoa/neural/generator.py", line 119, in generate_batch
    for b in range(batch_size)]
  File "/home/cocoa/cocoa/neural/generator.py", line 109, in get_bos
    bos = batch.decoder_inputs[gt_prefix-1][b].data.cpu().numpy()[0]
IndexError: too many indices for array
2019-03-10T12:46:45Z {'REMOTE_PORT': '49500', 'HTTP_HOST': 'xxx', 'REMOTE_ADDR': '::ffff:xxx', (hidden keys: 24)} failed with IndexError

I don't know the reason for it, and my command is:

PYTHONPATH=. python web/chat_app.py --host 0.0.0.0 --port 5000 --config web/app_params_allsys.json --schema-path data/craigslist-schema.json --scenarios-path data/scenarios.json --price-tracker-model data/price_tracker.pkl --templates data/templates.pkl --policy data/model.pkl

Other informations:

System: Ubuntu18.04
Python: 2.7

Please let me know if there is any solutions for this problem, thanks.

hmm. it looks like the decoder_inputs is empty. when does this error happen? does it happen deterministically?

@hhexiy yes, it happened deterministically. It happended when I had trained my manager and imporved it with RL, and I had trained with both modular approach and end-to-end approach. the only strange thing at that period was that I couldn't use RL on the end-to-end one with parameters --agents hybrid hybrid as suggested, because when I use the suggested parameter, I got the error as follows:

Traceback (most recent call last):
  File "reinforce.py", line 60, in <module>
    model = system.env.model
AttributeError: 'HybridSystem' object has no attribute 'env'

I had replaced that parameter with --agents pt-nerual pt-nerual and that works, I don't if that matters. If this is the point, could you tell me how to fix it?

Hi sorry that was a doc error... I've updated it. Training RL agents should always specify --agents pt-neural pt-neural since it actually refers to the policy model. Otherwise we cannot backprop through the policy.