I want to add part of speech features into my word vector after embedding in Keras. I would like to add them as one hot and concat them after embedding. But the part of speech of a word is dynamic so I can't use another embedding layer for part of speech one hot look up and combine two embedding layers.
Asked
Active
Viewed 1,237 times
0
-
Do you have POS feature as input? – sathyz Jul 19 '18 at 06:43
-
No. But I will generate POS feature using some packages. – Zedom Jul 19 '18 at 06:48
-
so in your case you have feature x and you need [x, x1] where x1 = f(x). This can be done as preprocessing step, before feeding to model. – sathyz Jul 19 '18 at 07:07
2 Answers
1
Here is a simple approach, I'm assuming input as a word and its POS tag.
word = Input(...)
pos = Input(...)
emb = Embedding( ... ) (word)
layer = Concatenate()([emb, pos])
outputs = .... # your processing
model = Model(inputs=[word,pos], outputs=outputs)

sathyz
- 1,401
- 10
- 12
-
-
-
Refer [Keras functional API](https://keras.io/getting-started/functional-api-guide/). In this case, you could just do `outputs = Dense(10, activation="softmax") (layer)` – sathyz Aug 30 '19 at 06:50
0
SathyZ just want to know we dont have to use embedding layer for pos tag
word = Input(...)
pos = Input(...)
emb_word = Embedding( ... ) (word)
emb_pos = Embedding( ... ) (pos)
layer = Concatenate()([emb, pos])
outputs = .... # your processing
model = Model(inputs=[word,pos], outputs=outputs)

pooja
- 31
- 2
- 7