У меня есть модель keras (Theano) для предсказания настроения на основании высказываний. Более того, я создал RESTful-сервер с Flask для упаковки модели в него. Моя цель - сравнить производительность с немасштабированной и масштабированной системой. Во-первых, я хотел попробовать с немасштабированным. Для перегрузки запросов я использую Apache Jmeter, который с течением времени моделирует 100 пользователей с помощью потоков.
Код доступен на этой странице github.
К сожалению, при выполнении тестов вышеупомянутая модель дает сбой с этой трассировкой:
Traceback (most recent call last):
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 2328, in __call__
return self.wsgi_app(environ, start_response)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 2314, in wsgi_app
response = self.handle_exception(e)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value.with_traceback(tb)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value.with_traceback(tb)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask_restful/__init__.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/flask_restful/__init__.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/sentiment-lstm/predict.py", line 54, in post
"value": self.predict([question])[0][0]
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/sentiment-lstm/predict.py", line 66, in predict
pred = self.__model.predict(x=X_test_pad)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/keras/engine/training.py", line 1169, in predict
steps=steps)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 294, in predict_loop
batch_outs = f(ins_batch)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1388, in __call__
return self.function(*inputs)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/theano/compile/function_module.py", line 917, in __call__
storage_map=getattr(self.fn, 'storage_map', None))
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/theano/compile/function_module.py", line 903, in __call__
self.fn() if output_subset is None else\
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/theano/scan_module/scan_op.py", line 963, in rval
r = p(n, [x[0] for x in i], o)
File "/home/lcarnevale/Dropbox/git/lcarnevale/sentiment-lstm/venv/lib/python3.6/site-packages/theano/scan_module/scan_op.py", line 952, in p
self, node)
File "scan_perform.pyx", line 546, in theano.scan_module.scan_perform.perform
TypeError: 'NoneType' object does not support item assignment
Apply node that caused the error: forall_inplace,cpu,scan_fn}(Shape_i{1}.0, Subtensor{int64:int64:int8}.0, IncSubtensor{InplaceSet;:int64:}.0, DeepCopyOp.0, Shape_i{1}.0, Subtensor{::, int64:int64:}.0, InplaceDimShuffle{x,0}.0, Subtensor{::, int64:int64:}.0, Subtensor{::, :int64:}.0, InplaceDimShuffle{x,0}.0, Subtensor{::, :int64:}.0, Subtensor{::, int64:int64:}.0, InplaceDimShuffle{x,0}.0, Subtensor{::, int64:int64:}.0, Subtensor{::, int64::}.0, InplaceDimShuffle{x,0}.0, Subtensor{::, int64::}.0)
Toposort index: 44
Inputs types: [TensorType(int64, scalar), TensorType(float32, 3D), TensorType(float32, (True, False, False)), TensorType(float32, (True, False, False)), TensorType(int64, scalar), TensorType(float32, matrix), TensorType(float32, row), TensorType(float32, matrix), TensorType(float32, matrix), TensorType(float32, row), TensorType(float32, matrix), TensorType(float32, matrix), TensorType(float32, row), TensorType(float32, matrix), TensorType(float32, matrix), TensorType(float32, row), TensorType(float32, matrix)]
Inputs shapes: ['No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes', 'No shapes']
Inputs strides: ['No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides', 'No strides']
Inputs values: [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]
Outputs clients: [[], [], [InplaceDimShuffle{1,0,2}(forall_inplace,cpu,scan_fn}.2)]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
Я не совсем уверен, что здесь ошибка. Может ли это быть призрак из-за проблемы с памятью? Или что?
Лоренцо.