Obtaining a prediction in Keras

后端 未结 1 1137
春和景丽
春和景丽 2020-12-31 14:40

I have successfully trained a simple model in Keras to classify images:

model = Sequential()

model.add(Convolution2D(32, 3, 3, border_mode=\'valid\', input_         


        
相关标签:
1条回答
  • 2020-12-31 15:13

    Softmax might yield "one-hot" like output. Consider the following example:

    # Input; Exponent; Softmax value 
    20    485165195  0.99994
     9         8103  0.00002
     5          148  0.00000
    10        22026  0.00005
    ------------------------
    # Sum 485195473  1
    

    Since the exponential function grows very fast softmax starts yielding one-hot like output starting from order of magnitude 1. In Keras implementation of the softmax function the maximum value is subtracted from the input, but in the stated above case it won't make any difference.

    Possible ways to fix this:

    1. Make sure that input images are rescaled, so that pixels values are between 0 and 1.

    2. Add some regularizers to your model.

    0 讨论(0)
提交回复
热议问题