Maybe it is a dummy question but I'd like to know whether I can have my output vector to meet specific requirements.
I have multiple outputs (that are not binary) and I want their sum to be 1. I want my model to do some kind of evaluation in order for my output vector to meet this requirement.
You can either:
softmax
activation at the end of your model, or Softmax:
Just add Activation('softmax')
at the end of the model.
This will perform some log operations though, and may be adding some extra conditions you do not want.
Custom normalizing:
Simply add this layer:
import keras.backend as K
Lambda(lambda x: x / K.sum(x), output_shape=optional_with_tensorflow)
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.