TransWikia.com

Problems with class embedding in keras

Data Science Asked on February 7, 2021

I am doing a toy example with mushroom dataset to learn class embedding with keras:

I am trying to embed a single feature:

inputs = Input(shape=[1])
emb = Embedding(input_dim=cap_shape_dummy.shape[1], output_dim=3)(inputs)
output = Dense(units=1,activation='sigmoid')(emb)
model = Model(inputs=inputs,outputs=output)

However I always receive the same error when I try to fit the model:

Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (8124, 1)

Am I doing anything wrong? Did I miss anything with category embedding?
Thanks.

One Answer

inputs = Input(shape=[1]) emb = Embedding(input_dim=cap_shape_dummy.shape[1], output_dim=3)(inputs) x = Flatten()(emb) output = Dense(units=1,activation='sigmoid')(x) model = Model(inputs=inputs,outputs=output)

Answered by user100853 on February 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP