Categories
Misc

Getting an error during Concatenation while employing Attention to my seq2seq model?

Hi everyone,

I’m trying to implement my own seq2seq model and employ the widely recommended attention layer on it. Oddly getting an error during the concatenation like below:

2 frames/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)53 ctx.ensure_initialized()54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,—> 55 inputs, attrs, num_outputs)56 except core._NotOkStatusException as e:57 if name is not None:InvalidArgumentError: Graph execution error:Detected at node ‘model_3/concat_layer/concat’ defined at (most recent call last):File “/usr/lib/python3.7/runpy.py”, line 193, in _run_module_as_main”__main__”, mod_spec)File “/usr/lib/python3.7/runpy.py”, line 85, in _run_codeexec(code, run_globals)File “/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py”, line 16, in <module>app.launch_new_instance()File “/usr/local/lib/python3.7/dist-packages/traitlets/config/application.py”, line 846, in launch_instanceapp.start()File “/usr/local/lib/python3.7/dist-packages/ipykernel/kernelapp.py”, line 499, in startself.io_loop.start()File “/usr/local/lib/python3.7/dist-packages/tornado/platform/asyncio.py”, line 132, in startself.asyncio_loop.run_forever()File “/usr/lib/python3.7/asyncio/base_events.py”, line 541, in run_foreverself._run_once()File “/usr/lib/python3.7/asyncio/base_events.py”, line 1786, in _run_oncehandle._run()File “/usr/lib/python3.7/asyncio/events.py”, line 88, in _runself._context.run(self._callback, *self._args)File “/usr/local/lib/python3.7/dist-packages/tornado/platform/asyncio.py”, line 122, in _handle_eventshandler_func(fileobj, events)File “/usr/local/lib/python3.7/dist-packages/tornado/stack_context.py”, line 300, in null_wrapperreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py”, line 452, in _handle_eventsself._handle_recv()File “/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py”, line 481, in _handle_recvself._run_callback(callback, msg)File “/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py”, line 431, in _run_callbackcallback(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/tornado/stack_context.py”, line 300, in null_wrapperreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py”, line 283, in dispatcherreturn self.dispatch_shell(stream, msg)File “/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py”, line 233, in dispatch_shellhandler(stream, idents, msg)File “/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py”, line 399, in execute_requestuser_expressions, allow_stdin)File “/usr/local/lib/python3.7/dist-packages/ipykernel/ipkernel.py”, line 208, in do_executeres = shell.run_cell(code, store_history=store_history, silent=silent)File “/usr/local/lib/python3.7/dist-packages/ipykernel/zmqshell.py”, line 537, in run_cellreturn super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py”, line 2718, in run_cellinteractivity=interactivity, compiler=compiler, result=result)File “/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py”, line 2822, in run_ast_nodesif self.run_code(code, result):File “/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py”, line 2882, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File “<ipython-input-15-f9cbfc42a957>”, line 491, in <module>train()File “<ipython-input-15-f9cbfc42a957>”, line 321, in train1)[:, 1:]))File “/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py”, line 64, in error_handlerreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/engine/training.py”, line 1384, in fittmp_logs = self.train_function(iterator)File “/usr/local/lib/python3.7/dist-packages/keras/engine/training.py”, line 1021, in train_functionreturn step_function(self, iterator)File “/usr/local/lib/python3.7/dist-packages/keras/engine/training.py”, line 1010, in step_functionoutputs = model.distribute_strategy.run(run_step, args=(data,))File “/usr/local/lib/python3.7/dist-packages/keras/engine/training.py”, line 1000, in run_stepoutputs = model.train_step(data)File “/usr/local/lib/python3.7/dist-packages/keras/engine/training.py”, line 859, in train_stepy_pred = self(x, training=True)File “/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py”, line 64, in error_handlerreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py”, line 1096, in __call__outputs = call_fn(inputs, *args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py”, line 92, in error_handlerreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/engine/functional.py”, line 452, in callinputs, training=training, mask=mask)File “/usr/local/lib/python3.7/dist-packages/keras/engine/functional.py”, line 589, in _run_internal_graphoutputs = node.layer(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py”, line 64, in error_handlerreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py”, line 1096, in __call__outputs = call_fn(inputs, *args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py”, line 92, in error_handlerreturn fn(*args, **kwargs)File “/usr/local/lib/python3.7/dist-packages/keras/layers/merge.py”, line 183, in callreturn self._merge_function(inputs)File “/usr/local/lib/python3.7/dist-packages/keras/layers/merge.py”, line 531, in _merge_functionreturn backend.concatenate(inputs, axis=self.axis)File “/usr/local/lib/python3.7/dist-packages/keras/backend.py”, line 3313, in concatenatereturn tf.concat([to_dense(x) for x in tensors], axis)Node: ‘model_3/concat_layer/concat’ConcatOp : Dimension 1 in both shapes must be equal: shape[0] = [128,7,300] vs. shape[1] = [128,128,300][[{{node model_3/concat_layer/concat}}]] [Op:__inference_train_function_43001]

You can reach the whole Python code from here: https://pastebin.pl/view/16b32d92 (I could not share it here as it was too long to be included here).

Could you please help me to find out what I’m missing?

Many many thanks in advance!

p.s. I’m using Keras for the implementation.

submitted by /u/talhak
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.