xyz
xyz

Reputation: 57

How to specify the output labels to keras lstm

I am new to Keras and I want to predict the polarity of each word in a sentence using LSTM. I am representing each sentence, by the corresponding pre trained word vectors. So my input representation is (maxlen,input_dimensions). But I am not being able to understand how to give the labels. For each sentence, the word can be in 3 classes(pos/neg/neutral). So it will something like [0,2,0,0,1.....]. How do I give this output to a sequential model?

Upvotes: 0

Views: 879

Answers (1)

WestCoastProjects
WestCoastProjects

Reputation: 63062

When calling

model.fit

you will supply the inputs and optionally the expected output . Usually the input is called 'X' and the output 'y'.

The input will include a dimension representing the sentence/phrase: you need to decide how long this will be for training. Note: another related consideration is the mini-batch size.

The output will have one less dimension than the input. You want to put the next word after the sentence in the same input array spot (by ordinal): this is the expected output for sentence K where k is the ordinal within the input array and the corresponding ordinal in the output array.

Upvotes: 2

Related Questions