简体   繁体   中英

How to ignore some input layer, while predicting, in a keras model trained with multiple input layers?

I'm working with neural networks and I've implemented the following architecture using keras with tensorflow backend:

在此处输入图片说明

For training, I'll give some labels in the layer labels_vector , this vector can have int32 values (ie: 0 could be a label). For the testing phase, I need to just ignore this input layer, if I set it to 0 results could be wrong since I've trained with labels that can be equal to 0 vector. Is there a way to simply ignore or disable this layer on the prediction phase? Thanks in advance.

How to ignore some input layer ?

You can't . Keras cannot just ignore an input layer as the output depends on it.

One solution to get nearly what you want is to define a custom label in your training data to be the null value. Your network will learn to ignore it if it feels that it is not an important feature.

If labels_vector is a vector of categorical labels, use one-hot encoding instead of integer encoding . integer encoding assumes that there is a natural ordered relationship between each label which is wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM