title: Keras : Value error : setting an array element with a sequence
body: <h2>Context :</h2>
  
  <p>I am just starting in Deep Learning and I have to implement a model in Python that can detect the inference between two sentences (label is neutral, contradiction or entailment).
  The data set is formatted as follows: </p>
  
  <pre><code>| index   | sentence_1   | sentence_2   | label  |
  |------------------------------------------------|
  | 1       | blabla       | blabla       | neutral|
  </code></pre>
  
  <p>To accomplish this task, I chose to use Keras which seemed relatively easy to use.
  I encoded the sentences with Glove embedded vectors (<code>dim=50</code>) and then padded them with <code>maxlen=80</code>. </p>
  
  <p>I end up with a new panda dataframe : </p>
  
  <pre><code>| index   | sentence_1_padded   | sentence_2_padded   | label        | target |
  |--------------------------------------------------------------------|--------|
  | 1       | matrix 80*50        | matrix 80*50        | neutral      | 2      |
  | ...     | ...                 | ...                 |  ...         |  ...   |
  | 5000    | matrix 80*50        | matrix 80*50        | contradiction| 0      |
  </code></pre>
  
  <p>Each embedded vector and each sequence is a numpy array.</p>
  
  <p>I want to train my model using this transformed dataset. </p>
  
  <p>So I built this model : </p>
  
  <pre><code>vocab_size = len(glove_wordmap)+1
  X = dataset_processed[['sentence_1_padded', 'sentence_2_padded']]
  y = dataset_processed[['target']]
  
  inputs = Input(shape=(2,))
  embedding_layer = Embedding(vocab_size, 128)(inputs)
  x = LSTM(64)(embedding_layer)
  x = Dense(32, activation='relu')(x)
  
  predictions = Dense(3, activation='softmax')(x)
  
  model = Model(inputs=[inputs], outputs=predictions)
  model.compile(optimizer='adam',
                loss='categorical_crossentropy',
                metrics=['acc'])
  
  model.fit(X, to_categorical(y), epochs=5, batch_size=32, validation_split=0.25)
  </code></pre>
  
  <p>and I have the following error that keeps coming back: </p>
  
  <pre><code>Train on 3750 samples, validate on 1250 samples
  Epoch 1/5
  ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-248-ddab59c5a43a&gt; in &lt;module&gt;()
  ----&gt; 1 model.fit(X, to_categorical(y), epochs=5, batch_size=32, validation_split=0.25)
  
  4 frames
  /usr/local/lib/python3.6/dist-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
     1176                                         steps_per_epoch=steps_per_epoch,
     1177                                         validation_steps=validation_steps,
  -&gt; 1178                                         validation_freq=validation_freq)
     1179 
     1180     def evaluate(self,
  
  /usr/local/lib/python3.6/dist-packages/keras/engine/training_arrays.py in fit_loop(model, fit_function, fit_inputs, out_labels, batch_size, epochs, verbose, callbacks, val_function, val_inputs, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps, validation_freq)
      202                     ins_batch[i] = ins_batch[i].toarray()
      203 
  --&gt; 204                 outs = fit_function(ins_batch)
      205                 outs = to_list(outs)
      206                 for l, o in zip(out_labels, outs):
  
  /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in __call__(self, inputs)
     2977                     return self._legacy_call(inputs)
     2978 
  -&gt; 2979             return self._call(inputs)
     2980         else:
     2981             if py_any(is_tensor(x) for x in inputs):
  
  /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in _call(self, inputs)
     2915                 array_vals.append(
     2916                     np.asarray(value,
  -&gt; 2917                                dtype=tf.as_dtype(tensor.dtype).as_numpy_dtype))
     2918         if self.feed_dict:
     2919             for key in sorted(self.feed_dict.keys()):
  
  /usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
       83 
       84     """
  ---&gt; 85     return array(a, dtype, copy=False, order=order)
       86 
       87 
  
  ValueError: setting an array element with a sequence.
  </code></pre>
  
  <p>I have read this <a href="https://stackoverflow.com/questions/44573784/keras-neural-network-error-setting-an-array-element-with-a-sequence">post</a>, but it doesn't help since I've checked the dimensions and the type of elements in X, and each sequence in each column is a numpy array of shape (80,50).</p>
  
  <p>I would really be grateful to the person who has a solution to my problem, or to someone who knows a beginner's tutorial to solve this kind of problem easily.</p>
  
  <p>Thank you for your help ! </p>
  
  <p>PS: Feel free to tell me if I'm off to a bad start to solve this problem</p>