ValueError: setting an array element with a sequence

username: Deb_Prakash_Chatterj
cooked: <p>Guys, I am making a Sentiment Analysis Classifier and now I am stuck with a problem called <code>ValueError: setting an array element with a sequence.</code><br>
The dataset is twitter dataset, as it can contain mainly un-processed tweets, so I first processed the data, by cleaning the punctuations and un-used words or not-meaningful words. Then as we need to tokenized our data to feed it into the embedding and LSTM layer, so I did it before splitting the data into train set and test set.<br>
Size of train and test set -<br>
<code>(31962,) (17197,)</code> and train[‘label’](label part) is <code>(31962,)</code>.<br>
This is my classifier, that I made using keras to do it with LSTM.</p>
<pre><code class="lang-auto">max_len=50
max_features=20000
classifier= Sequential()
classifier.add(Embedding(max_features, 100, mask_zero=True))
classifier.add(LSTM(200, dropout=0.3, recurrent_dropout=0.3, return_sequences=False))
classifier.add(Dense(1, activation='softmax'))
classifier.compile(loss = 'sparse_categorical_crossentropy', optimizer='adam',metrics = ['accuracy'])
classifier.summary()
</code></pre>
<p>Now after making callback and using classifier.fir function, it should return a training loss value along with epoch count, but it is giving me an unexpected error shown below -</p>
<pre><code class="lang-auto">callback = [EarlyStopping(monitor='val_loss', patience=2),ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]
classifier.fit(X_train, y_train,batch_size=100,epochs=5,callbacks=callback ,validation_data=(X_test, y_test))

----&gt; 2 classifier.fit(X_train, y_train,batch_size=100,epochs=5,callbacks=callback ,validation_data=(X_test, y_test))

    537     """
--&gt; 538     return array(a, dtype, copy=False, order=order)
    539 
    540 

ValueError: setting an array element with a sequence.
</code></pre>
<p>Can anyone of you help me to resolve this error, I am almost done with my project, but this is out of my knowledge. Please help and also please ask if anything is unclear. Thanks.</p>

username: tom
cooked: <p>While we try to help with questions that use libraries and models built on top of PyTorch when people have errors that ultimately come down how they use PyTorch, and Keras is bound to be a fine library, it would seem that most people here are not using it as much.</p>
<p>I would suggest using <a href="https://keras.io/#support" rel="nofollow noopener">Keras’ suggested support venues</a> because ultimately there you will find people using it every day.</p>
<p>That said, do check out <a href="https://fast.ai/" rel="nofollow noopener">fast.ai</a> if you want a PyTorch-based library that roughly has similar intentions as Keras.</p>
<p>Best regards</p>
<p>Thomas</p>

username: Deb_Prakash_Chatterj
cooked: <p>Sir, I am sorry that I posted in the wrong group, but sir, can you tell me or help me regarding this including in the PyTorch. Actually I am almost done in this project and this can give me the end of this project, I hope you are getting me. So, can I personally Message you here regarding this? Because, I am not getting how can I do this in PyTorch?<br>
Still I am very much interested to do in PyTorch as I have done several projects in PyTorch.<br>
Thanks, and any lead will be helpful to me.</p>