0

Trying to implement bidirectional LSTM model with glove embedding in Python using keras. Model architecture is as below:

enter image description here

The model works fine when it is run without any preprocessing of input data. Below image shows the output of the model:

enter image description here

As a part of pre-processing, the input data is lemmatized using Spacy and then passed into the model.

Lemmatization Pre-processing code:

nlp = spacy.load(“en_core_web_sm-2.1.0”)
doc = nlp(sentence)
lemma_sent = “ “.join([token.lemma_ for token in doc])

Below method does the model fit:

model.fit(data_train,train_label,epoch=5,batch_size=32,verbose=True,validation_data=[data_test,test_label])

But the model is giving output as below for each epoch(after lemmatization of train and test data):

enter image description here

Please help on why the model runs like above with lemmatization. Model summary looks same for both with and without lemmatization.

Anvitha
  • 89
  • 4
  • 1
    Please include text as plain text in code blocks rather than images. It's much easier to read and search. Without any information about how you're processing the data with spacy, it's very hard to figure out what might be going on. – aab Oct 16 '19 at 12:33
  • I don't know why preprocessed training isn't outputing properly, but I notice it doesn't have any Validation info. Are you Not feeding validation data on purpose? Are you implementing any custom metrics or callbacks. I'd look at your call to Keras training and any custom metrics or callbacks. None of that code is included here. If you post it, someone might be able to see what's happening. – bivouac0 Oct 17 '19 at 13:09
  • @bivouac0 , I have updated the question. Please help. – Anvitha Oct 21 '19 at 12:52
  • There is nothing obviously wrong with the above code. You need to post an extracted segment of code that is FULLY RUNNABLE and exhibits the problem, if you want someone to help. For instance, you have "lemma_sent" but this doesn't show up in your fit command and there is no info on the other data that is going into "fit". You need to provide all that code and some sample data of what's in those variables. You might also want to provide info on your environment (windows, Linux, ...) and versions since this looks like some oddity with the Keras code. – bivouac0 Oct 21 '19 at 13:06
  • You might search for other post such as https://stackoverflow.com/questions/41442276/keras-verbose-training-progress-bar-writing-a-new-line-on-each-batch-issue to see if manipulating the terminal params can help. It's not obvious how/if this is connected to your lemmatization. – bivouac0 Oct 21 '19 at 13:12

0 Answers0