python - Add categorical feature before the dense layer in Keras? -


i working on cnn model , want add new categorical feature before dense layer. tried concatenate feature flattened output of cnn layer looks concatenate function in keras requires input of tensors , not arrays. how should go it? here code have tried far:

model = sequential() model.add(conv2d(128, (6, 6), padding='same')) model.add(activation('relu')) model.add(conv2d(128, (6, 6))) model.add(activation('relu')) model.add(maxpooling2d(pool_size=(2, 2))) model.add(dropout(0.25)) model.add(flatten()) 

i trying use concatenate function can join tensors, feature numpy array of shape (1, 3). appreciated.

you should create new model on side of actual model. second model take in input numpy array , nothing else.

then concatenate them.

like ->

m1 = sequential() m1.add(conv2d(128, (6, 6), padding='same')) m1.add(activation('relu')) m1.add(conv2d(128, (6, 6))) m1.add(activation('relu')) m1.add(maxpooling2d(pool_size=(2, 2))) m1.add(dropout(0.25)) m1.add(flatten())  m2 = sequential() m2.add(input()) # put needed infos input numpy array #don't forget flatten if needed ?  model = sequential() model.add(merge([m1,m2], mode='concat')) #then add final layer. #to train it, in place of normal var x_train, you'll use [x_train,yournumpyarray] in model.train method 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -