我试图做一个多标签分类器。它有5个标签。我通过ImageDataGenerators进行了培训,然后我想手动测试系统,但是我无法执行该操作,因为系统给了我奇怪的答案,看起来像是概率。它们可以是负数或大于1。我不知道如何纠正它或在哪里犯了错误。

xception = Xception(include_top=False, weights='imagenet', pooling='avg')
x = Dense(5, name='prediction')(xception.output)
model = Model(xception.inputs, x)

model.compile(loss='categorical_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])


# # Creating Image Generators
# Based on ImageDataGenerator class.

train_dir = 'processed_dataset/train'
val_dir = 'processed_dataset/val'
test_dir = 'processed_dataset/test'
img_width, img_height = 300, 300
input_shape = (img_width, img_height, 3)
epochs = 40
batch_size = 8
nb_train_samples = 442
nb_validation_samples = 23
nb_test_samples = 23

datagen = ImageDataGenerator(
        rotation_range=40,
        width_shift_range=0.2,
        height_shift_range=0.2,
        rescale=1./255,
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True,
        fill_mode='nearest')


# Generator for training
train_generator = datagen.flow_from_directory(
    train_dir,
    target_size=(img_width, img_height),
    batch_size=batch_size,
    class_mode='categorical')


# Generator for validation
val_generator = datagen.flow_from_directory(
    val_dir,
    target_size=(img_width, img_height),
    batch_size=batch_size,
    class_mode='categorical')


# Generator for testing
test_generator = datagen.flow_from_directory(
    test_dir,
    target_size=(img_width, img_height),
    batch_size=batch_size,
    class_mode='categorical')


# Learning the model using generators

model.fit_generator(
    train_generator,
    steps_per_epoch=nb_train_samples // batch_size,
    epochs=epochs,
    validation_data=val_generator,
    validation_steps=nb_validation_samples // batch_size)


# Evaluating the accuracy score of the system
scores = model.evaluate_generator(test_generator, nb_test_samples // batch_size)
print("Accuracy on the test set: %.2f%%" % (scores[1]*100))



test_imgs, test_labels = next(test_generator)
test_labels

predictions = model.predict_generator(test_generator, steps=1, verbose=0)
predictions


现在,test_labels给我以下输出:

array([[0., 0., 1., 0., 0.],
   [0., 0., 0., 0., 1.],
   [1., 0., 0., 0., 0.],
   [0., 0., 1., 0., 0.],
   [1., 0., 0., 0., 0.],
   [0., 0., 1., 0., 0.],
   [0., 1., 0., 0., 0.],
   [0., 0., 1., 0., 0.]], dtype=float32)


预测给了我这个:

array([[[[ 7.52097219e-02,  5.41056037e-01, -4.95246649e-02,
      -8.79141092e-02, -5.37679076e-01],
     [ 8.59603286e-02,  4.42841858e-01,  2.17923790e-01,
       9.83133465e-02, -1.15531743e-01],
     [ 6.49649799e-02,  6.98908925e-01,  1.38851732e-01,
      -6.28874898e-01, -2.87516713e-01],
     ...,
     [-5.38311005e-02,  3.90918076e-01,  8.76815915e-02,
      -6.06191695e-01, -4.36177373e-01],
     [ 1.97946265e-01, -1.32776499e-01,  2.11007819e-02,
      -1.76965401e-01, -3.89797568e-01],
     [ 2.52179474e-01, -2.43290961e-01, -4.47124951e-02,
      -2.76472978e-02, -5.58846176e-01]],

    [[ 1.79345787e-01, -2.39991426e-01, -7.36931980e-01,
      -2.05338299e-02, -2.79670715e-01],
     [ 1.93363309e-01,  6.22152686e-02, -3.61416578e-01,
      -5.90571404e-01,  2.43387222e-02],
     [ 4.81128693e-04,  1.02495873e+00, -5.00306845e-01,
      -1.19032454e+00, -3.84473145e-01],
     ...,
     [ 1.01383895e-01,  5.54112792e-01, -4.92577612e-01,
      -9.82546687e-01, -3.58846277e-01],
     [ 1.44275457e-01,  2.45612651e-01, -2.55063474e-02,
      -1.36065081e-01, -5.27489424e-01],
     [-4.50903028e-02,  2.70254016e-02, -1.32244378e-01,
      -1.68490663e-01, -5.82786441e-01]],

    [[-1.83367491e+00, -1.40455127e+00, -2.88795042e+00,
      -8.70022953e-01, -3.66152048e-01],
     [-1.96281028e+00,  1.41523457e+00, -1.92235279e+00,
      -2.13001728e-01, -1.25367165e-01],
     [-7.24048257e-01,  2.31916142e+00, -4.72892284e-01,
       2.84373224e-01,  2.22759843e-01],
     ...,
     [ 4.44787741e-01,  1.41101933e+00, -3.08741093e-01,
      -1.77997321e-01, -6.85059667e-01],
     [ 3.86560917e-01,  7.81786919e-01, -1.02287531e-01,
       2.26198703e-01, -7.42644906e-01],
     [ 4.92909461e-01,  4.09601361e-01, -1.24008060e-02,
       4.90530610e-01, -3.58241975e-01]],

    ...,

    [[ 1.34195596e-01,  9.05789196e-01, -3.27457100e-01,
      -2.72707641e-02, -5.75808585e-02],
     [ 3.48491669e-02,  7.73825049e-01, -8.10453951e-01,
      -4.55976486e-01,  7.19135404e-02],
     [ 9.90181565e-02,  1.65191579e+00, -8.58390450e-01,
      -1.44752055e-01,  1.11153495e+00],
     ...,
     [ 1.02726197e+00,  7.24114060e-01, -5.04094720e-01,
      -1.10842264e+00,  7.84971535e-01],
     [ 5.04721522e-01,  1.01551962e+00, -9.06502008e-01,
      -1.18128228e+00,  7.52095342e-01],
     [-5.78828692e-01,  4.63467002e-01, -7.49408603e-01,
      -3.87779921e-01, -6.45416617e-01]],

    [[-4.17019367e-01,  3.16981822e-02, -5.89770079e-03,
       4.02818799e-01, -9.62504297e-02],
     [-1.35728955e-01, -4.12908316e-01,  3.20006192e-01,
       1.73515067e-01, -1.40590072e-01],
     [ 4.33863699e-01, -3.86119306e-01, -7.91982114e-02,
      -3.16189915e-01,  5.20472348e-01],
     ...,
     [ 1.82109082e+00,  1.94166586e-01, -5.79492450e-01,
      -3.93155515e-01,  5.31377137e-01],
     [ 1.08623457e+00,  7.89248347e-01, -9.01886463e-01,
      -4.46968585e-01, -1.74912810e-01],
     [-3.41510653e-01,  4.51059341e-01, -7.65451312e-01,
      -1.59630507e-01, -4.96455640e-01]],

    [[-1.37914598e-01, -2.57007927e-01, -2.20677495e-01,
       1.29387960e-01,  7.42561668e-02],
     [ 3.57518733e-01, -2.02521026e-01, -3.28127176e-01,
       1.83442786e-01,  3.61326337e-03],
     [ 4.92624342e-01, -1.78903997e-01,  9.70426947e-02,
       1.15486935e-01,  4.27795678e-01],
     ...,
     [ 1.41865325e+00, -1.02405399e-02, -9.81141925e-02,
      -2.44841397e-01,  2.14931667e-02],
     [ 5.51047087e-01,  4.96876895e-01, -8.94319654e-01,
      -3.99587899e-02,  2.81938583e-01],
     [-5.39022684e-01,  2.43451580e-01, -5.92756987e-01,
       1.12866879e-01, -4.50303912e-01]]],


   [[[-1.83097810e-01,  6.84144497e-01, -7.69550502e-01,
       8.68627727e-01, -2.22709656e-01],
     [-5.92741728e-01,  1.51784450e-01, -3.88990521e-01,
       1.01064312e+00, -5.72405517e-01],
     [-1.39353657e+00, -1.49367034e-01, -5.02825260e-01,
       1.03664172e+00, -7.53440440e-01],
     ...,
     [ 8.51202607e-01,  7.41849661e-01, -9.04791594e-01,
      -2.36053631e-01,  5.04501641e-01],
     [ 2.12731928e-01, -2.85548568e-01, -9.00105357e-01,
       8.05069506e-02, -4.06455994e-01],
     [ 2.55032003e-01, -4.90147203e-01, -1.21454895e-01,
      -2.00196147e-01,  1.09439880e-01]],

    [[-8.17323148e-01,  4.44754750e-01, -8.37389469e-01,
       5.46341121e-01,  4.94321972e-01],
     [-2.02778125e+00, -8.33413243e-01, -2.61943251e-01,
      -4.83462214e-03,  3.62069070e-01],
     [-1.57397735e+00, -1.21108556e+00, -6.78366661e-01,
       5.15946925e-01,  4.34342623e-02],
     ...,
     [-2.30410457e-01,  1.23731506e+00, -2.72230577e+00,
      -4.95598316e-01,  9.59013224e-01],
     [-5.49526811e-01,  3.68986040e-01, -1.85951960e+00,
      -3.30176592e-01,  1.01189268e+00],
     [ 8.02167132e-02, -2.48757601e-02, -5.89860201e-01,
       7.26686716e-02,  4.63002503e-01]],

    [[-5.70342183e-01,  1.00894876e-01, -7.74569750e-01,
       2.41944373e-01, -1.19897217e-01],
     [-1.20720732e+00, -9.24345016e-01, -5.86426437e-01,
      -1.53923392e-01, -4.62331712e-01],
     [-7.13050365e-01, -1.33217061e+00, -7.86076546e-01,
      -2.22010046e-01, -6.32698417e-01],
     ...,
     [ 2.41711795e-01,  1.15276492e+00, -2.77725124e+00,
      -8.71360838e-01,  1.21103406e+00],
     [-5.39063096e-01,  1.46569526e+00, -3.03291845e+00,
      -7.49805629e-01,  1.23009539e+00],
     [ 4.72337872e-01,  7.43141711e-01, -9.98269618e-01,
      -2.55082250e-01,  6.97237730e-01]],

    ...,

    [[-8.97521913e-01, -2.18475014e-01, -4.22037899e-01,
       3.81799519e-01, -4.04932141e-01],
     [-5.91429949e-01,  3.82492617e-02, -1.24508452e+00,
       6.72841191e-01,  1.30095959e-01],
     [-1.81367898e+00, -3.50646377e-01, -1.30041862e+00,
      -6.32874966e-01, -7.77092576e-03],
     ...,
     [-1.37562728e+00,  1.80816591e-01, -1.30899990e+00,
      -1.52513552e+00, -2.86536902e-01],
     [-1.20952237e+00,  2.19834709e+00, -2.42691755e+00,
      -3.71934325e-01,  8.93743873e-01],
     [-5.38375974e-01,  7.26018965e-01, -1.27759957e+00,
       4.40124482e-01,  7.08007872e-01]],

    [[-1.10443616e+00, -4.09026861e-01, -1.15125775e-02,
       4.27500665e-01,  4.57156301e-02],
     [-8.55174303e-01, -3.66052747e-01, -5.04867315e-01,
       7.32684374e-01,  2.99848855e-01],
     [-1.01622462e+00,  1.60967886e-01, -5.75568676e-01,
      -6.35250032e-01, -1.73604071e-01],
     ...,
     [-7.85465896e-01,  8.28000069e-01, -2.58620930e+00,
      -2.36077642e+00,  5.02218843e-01],
     [-2.12391466e-02,  1.83450246e+00, -2.75204587e+00,
      -6.81238770e-01,  1.00321698e+00],
     [ 4.83697116e-01,  5.87888479e-01, -1.36865020e+00,
       4.94212985e-01,  2.40334690e-01]],

    [[-6.12910569e-01, -2.89814770e-01,  1.23900667e-01,
       6.29055619e-01, -3.00407231e-01],
     [-2.37547278e-01, -5.33289671e-01, -3.78314912e-01,
       1.12823749e+00,  3.17725033e-01],
     [-3.00657779e-01, -4.78583246e-01, -6.42191708e-01,
       2.08819807e-01,  1.84970975e-01],
     ...,
     [-7.69586027e-01,  1.42028713e+00, -1.61659014e+00,
      -2.11683798e+00,  1.05798185e-01],
     [-4.80629385e-01,  1.58191848e+00, -9.51906025e-01,
      -7.43460655e-01, -2.61611581e-01],
     [-2.59383619e-01,  6.07047081e-01, -2.16549337e-01,
       4.02391434e-01,  8.53861272e-02]]],


   [[[ 2.19264716e-01,  1.80342942e-01, -6.79925084e-04,
      -3.85786474e-01,  1.73509344e-02],
     [-9.20660198e-02,  2.60823786e-01, -4.38521773e-01,
      -4.17137653e-01, -5.87219298e-01],
     [ 3.35484505e-01,  4.86201435e-01, -5.05722404e-01,
       1.83470428e-01, -2.42839843e-01],
     ...,
     [ 9.95260626e-02, -6.76741302e-01, -1.55062914e+00,
      -1.93915224e+00,  1.85599029e-01],
     [-2.43680790e-01, -1.12695360e+00, -2.04525042e+00,
      -1.72817576e+00, -3.29362571e-01],
     [-2.97525853e-01, -8.73168290e-01, -1.41158104e+00,
      -9.66536701e-01, -5.90973377e-01]],

    [[-5.66102564e-02,  1.69532537e-01, -2.65555143e-01,
      -3.28358322e-01, -3.69028330e-01],
     [-2.68736541e-01,  6.79090619e-03, -3.59403759e-01,
      -7.96117127e-01, -6.02259636e-01],
     [-3.09453249e-01,  2.22328603e-01, -9.17185783e-01,
      -5.27001619e-02, -5.10420263e-01],
     ...,
     [-1.29235530e+00, -3.13198209e-01, -2.82991719e+00,
      -2.57532525e+00,  1.07784474e+00],
     [-1.09459186e+00, -5.51856875e-01, -3.68284655e+00,
      -2.13552904e+00,  1.02776110e+00],
     [-7.74189532e-02, -5.14578819e-01, -3.71007538e+00,
      -1.45961499e+00, -7.62989104e-01]],

    [[ 4.66368049e-01,  2.97895849e-01,  3.04840118e-01,
      -3.83194745e-01, -7.50639558e-01],
     [-2.68740952e-01, -1.41490519e-01,  2.21021920e-01,
       1.15534648e-01, -1.30901277e+00],
     [ 6.58517361e-01,  7.23964572e-02, -3.64375710e-02,
       1.22396636e+00, -6.63648307e-01],
     ...,
     [-1.56414342e+00, -3.52336824e-01, -3.14347076e+00,
      -1.75173032e+00,  8.34757686e-01],
     [-1.93781996e+00,  2.78123438e-01, -4.93014908e+00,
      -1.47512770e+00,  1.46738148e+00],
     [-6.08991683e-01,  7.94276834e-01, -4.98504829e+00,
      -1.10413778e+00,  1.01895213e-01]],

    ...,

    [[-5.20243824e-01, -5.51843703e-01, -2.58033603e-01,
      -2.22365141e-01, -4.29325223e-01],
     [-1.79190075e+00, -2.04155016e+00,  7.25815177e-01,
      -4.35511291e-01, -8.17587554e-01],
     [-1.64208114e+00, -1.63805628e+00,  6.83233500e-01,
       3.00381541e-01, -4.50374305e-01],
     ...,
     [-3.75656545e-01, -2.51724213e-01, -1.88207686e-01,
      -3.86871547e-02,  5.79151750e-01],
     [-2.75305390e-01, -8.69545639e-02, -8.39082479e-01,
      -7.92900324e-02,  9.91229773e-01],
     [-3.25641781e-01, -2.26463795e-01, -1.20980537e+00,
      -1.17907688e-01,  2.10901588e-01]],

    [[-8.56359422e-01, -1.08248591e+00,  2.49749631e-01,
      -1.08880021e-01,  2.67413259e-02],
     [-1.47091806e+00, -1.88285410e+00,  1.09791517e+00,
      -3.22843760e-01, -1.02435136e+00],
     [-1.48095536e+00, -7.62316525e-01,  1.27657712e+00,
      -5.97443223e-01, -8.11216831e-01],
     ...,
     [-3.45795989e-01,  3.11716199e-01,  1.23298287e-01,
       3.41657698e-02,  5.40752113e-01],
     [-5.38865387e-01,  1.06941797e-01, -1.32307172e-01,
      -3.10861677e-01,  1.95661172e-01],
     [-3.76878858e-01,  1.13853976e-01, -7.75436386e-02,
      -3.13877136e-01, -1.24399483e-01]],

    [[-4.66729999e-01,  1.28450096e-01, -4.86393988e-01,
      -2.50240207e-01, -1.04141450e+00],
     [-8.86957943e-01, -4.68761235e-01, -5.47460616e-02,
      -3.33873957e-01, -1.32679033e+00],
     [-1.26665640e+00,  3.19139212e-02,  1.09328461e+00,
      -6.06237233e-01, -8.13867748e-01],
     ...,
     [-5.84207177e-01,  5.84086537e-01,  3.98347676e-01,
       2.33056396e-02,  7.90394545e-02],
     [-3.50602686e-01,  1.33500606e-01,  2.33889878e-01,
       3.76633927e-02, -2.46354312e-01],
     [ 1.42287880e-01,  4.76878285e-01,  3.29360783e-01,
       2.78180242e-02, -1.29359767e-01]]],


   ...,


   [[[ 1.46021217e-01,  5.15166163e-01,  6.42497092e-03,
       2.10047305e-01, -5.99671364e-01],
     [ 2.76231736e-01,  2.98982233e-01,  2.88115889e-01,
       2.32200429e-01, -6.39735460e-02],
     [-4.44781214e-01,  1.45912302e+00,  4.93384957e-01,
       1.35454625e-01, -2.79690027e-02],
     ...,
     [ 8.27333927e-01,  1.83713055e+00,  1.44557953e-01,
      -7.67674565e-01,  2.45759535e+00],
     [ 6.98996067e-01,  4.54693258e-01, -5.64688072e-02,
      -1.54869109e-01,  2.50767410e-01],
     [ 9.59822536e-02,  2.38060236e-01, -1.56232610e-01,
       8.41926336e-02, -2.30810076e-01]],

    [[-1.09137297e-01,  1.13186799e-01,  1.16710458e-02,
      -1.58278719e-02, -2.54899174e-01],
     [-2.95275331e-01,  5.24003863e-01,  1.60899147e-01,
      -6.97276220e-02,  2.15586126e-01],
     [-4.35572237e-01,  8.93657327e-01, -3.47001195e-01,
       1.43726617e-01,  1.47935033e-01],
     ...,
     [ 9.16206092e-02,  8.24900270e-01, -3.53681266e-01,
       3.79393935e-01,  1.69526446e+00],
     [ 2.91864783e-01,  3.97536218e-01, -5.22625268e-01,
      -8.21618140e-02,  3.25788319e-01],
     [-9.19831097e-02,  2.37887740e-01, -2.47211754e-01,
      -2.40494609e-02, -1.15600847e-01]],

    [[-4.17404234e-01,  4.26486492e-01, -4.19323146e-03,
      -4.21829522e-03,  5.19865155e-02],
     [-3.43898237e-01,  1.25907421e+00,  2.32054144e-01,
       7.06444740e-01, -1.23097919e-01],
     [-6.78077221e-01,  2.31465411e+00,  7.59923756e-01,
       8.89178813e-01, -6.57979429e-01],
     ...,
     [-7.21525788e-01,  1.90616703e+00, -2.44078100e-01,
       1.15303183e+00,  3.68118733e-01],
     [-4.75895643e-01,  9.99899983e-01, -4.59014952e-01,
       1.76822886e-01,  3.67279142e-01],
     [-4.19832826e-01,  5.09469032e-01, -2.28665054e-01,
      -8.56926441e-02, -7.13551939e-02]],

    ...,

    [[-1.09364796e+00,  7.47790754e-01, -6.30517185e-01,
       9.64763820e-01, -9.49166656e-01],
     [-8.89622092e-01,  1.04416966e+00, -1.11987680e-01,
       1.17960978e+00, -7.91518927e-01],
     [-1.01954508e+00,  1.65915430e+00, -2.90566325e-01,
       9.16439474e-01, -6.82465136e-01],
     ...,
     [-5.70804358e-01,  1.44986546e+00,  4.54881340e-01,
       1.22483063e+00, -2.18070298e-02],
     [-6.16563737e-01,  1.58624887e+00,  7.11415172e-01,
       9.41769123e-01,  2.36040354e-02],
     [-5.09447873e-01,  1.13824022e+00,  3.62025261e-01,
       5.85387051e-02, -1.42430335e-01]],

    [[-6.95525467e-01,  3.81350160e-01, -9.55904901e-01,
       7.40139335e-02, -7.30462432e-01],
     [-1.17503285e+00,  8.78214061e-01, -1.08051455e+00,
       3.09868276e-01, -6.93305075e-01],
     [-5.25303900e-01,  8.87034118e-01, -7.42159605e-01,
       2.16955841e-01, -1.27436280e-01],
     ...,
     [ 7.07662106e-03,  7.35114932e-01,  2.85676599e-01,
       1.03725696e+00, -6.19800091e-02],
     [ 6.78142607e-02,  1.26432610e+00, -8.09367299e-02,
       9.55948234e-01, -2.91924328e-01],
     [-3.01641405e-01,  9.44184840e-01, -2.46870786e-01,
       5.38006842e-01, -1.33282691e-01]],

    [[-2.58389950e-01,  5.88255644e-01, -7.15478420e-01,
       1.99730471e-02, -4.35314178e-01],
     [-5.64473391e-01,  6.16480827e-01, -9.24921751e-01,
       3.64914179e-01, -8.73326302e-01],
     [-4.39013213e-01,  9.61618841e-01, -1.11723995e+00,
       5.80082357e-01, -5.67256451e-01],
     ...,
     [ 1.86858252e-01,  3.51035804e-01, -8.37046504e-01,
       4.67260957e-01, -8.18320811e-02],
     [ 2.45967776e-01,  6.56685650e-01, -6.38673067e-01,
       7.48460174e-01, -9.89019275e-02],
     [ 4.90868390e-02,  6.32709801e-01, -4.77524102e-01,
       3.14339131e-01, -3.41963410e-01]]],


   [[[ 1.58826485e-01,  1.91799104e-01, -3.18363726e-01,
       7.74042010e-02,  5.19555956e-02],
     [-2.24800706e-02,  3.66292268e-01, -1.79377079e-01,
      -2.02083007e-01,  2.27917463e-01],
     [-9.13226306e-02,  6.59206927e-01,  8.28242004e-02,
       5.34465671e-01,  2.18411371e-01],
     ...,
     [ 6.08833194e-01,  7.91696072e-01, -2.89375186e-02,
      -1.00860119e+00, -6.70631707e-01],
     [ 5.21096230e-01,  6.34132087e-01,  2.43262336e-01,
      -8.13222706e-01, -1.06721199e+00],
     [ 4.28706974e-01,  3.73350859e-01, -2.20415294e-01,
      -6.49214506e-01, -5.41059136e-01]],

    [[ 4.67009306e-01,  1.67656749e-01, -1.08979011e+00,
       4.42519784e-03,  3.66049886e-01],
     [ 7.16670394e-01, -9.78428200e-02, -9.16241348e-01,
      -9.24043208e-02,  4.30823296e-01],
     [-1.37665689e-01,  2.00978652e-01, -1.36108935e+00,
       3.09475362e-01,  1.51370138e-01],
     ...,
     [-7.62499809e-01,  1.80458593e+00, -9.54928517e-01,
      -3.14865112e-01, -1.52896023e+00],
     [-4.38860655e-02,  1.47695661e+00, -6.89137757e-01,
      -9.06191051e-01, -7.05127656e-01],
     [-1.19276524e-01,  7.38952875e-01, -7.85619318e-02,
      -5.03501654e-01, -1.13180399e-01]],

    [[ 2.06462026e-01,  2.82692432e-01, -1.15899730e+00,
       6.17671013e-01,  5.62405348e-01],
     [-1.79481149e-01,  6.95697427e-01, -3.63246500e-01,
       1.38479292e+00,  5.75057566e-02],
     [-1.63287973e+00,  6.70342267e-01, -1.71549034e+00,
       1.10036457e+00,  1.18404508e-01],
     ...,
     [-1.86131155e+00,  1.61656523e+00, -4.34207082e-01,
      -1.56839025e+00, -2.35358047e+00],
     [-8.78981829e-01,  2.26667285e+00,  4.83930707e-02,
      -2.87779737e+00, -1.19318080e+00],
     [ 5.12785673e-01,  1.28362536e+00,  5.47063470e-01,
      -2.38807130e+00, -4.61851209e-01]],

    ...,

    [[ 4.83658910e-01,  6.01587296e-01, -6.37129188e-01,
       3.37255478e-01,  4.38866392e-02],
     [ 2.47949064e-01,  1.96345344e-01, -8.23541045e-01,
       8.27636302e-01,  6.48281097e-01],
     [-9.42961693e-01,  5.84309578e-01, -9.76224780e-01,
       1.38779485e+00,  5.70707560e-01],
     ...,
     [-1.20508003e+00,  1.31211072e-01, -2.05090570e+00,
       1.22084290e-01, -2.49577854e-02],
     [-1.25588536e+00, -4.72412288e-01, -2.44941711e+00,
      -7.32854962e-01, -1.20768404e+00],
     [-1.91154599e-01,  6.53013468e-01, -1.08538842e+00,
      -1.62610793e+00, -7.37267435e-01]],

    [[ 6.09545410e-02,  1.35971889e-01, -5.12447774e-01,
       6.04172200e-02, -5.80774426e-01],
     [-3.94296288e-01,  2.70098448e-04, -4.34310764e-01,
       5.61170399e-01, -4.14130270e-01],
     [-6.89747810e-01,  8.06501508e-03, -1.52888000e-02,
       9.14169788e-01, -5.37817955e-01],
     ...,
     [-5.31186044e-01, -6.71589971e-01, -2.27104306e+00,
      -2.04336047e-02,  5.35233259e-01],
     [-1.06264687e+00, -8.30804169e-01, -2.70106578e+00,
      -2.68519878e-01, -4.25821722e-01],
     [-7.77629495e-01,  1.33242190e-01, -1.28198576e+00,
      -9.94475126e-01, -4.02960658e-01]],

    [[ 3.08561206e-01, -2.98327476e-01, -1.16769917e-01,
       8.15820470e-02, -1.85444534e-01],
     [ 2.60987431e-01, -2.82921821e-01,  4.16462839e-01,
       2.56793052e-01, -1.65614247e-01],
     [-2.32234597e-02, -2.99800485e-01,  4.03021693e-01,
       1.81421742e-01, -7.30518520e-01],
     ...,
     [ 2.73230493e-01, -6.22930050e-01, -9.57153678e-01,
       3.63736629e-01,  6.67109251e-01],
     [-1.79745808e-01, -4.37240183e-01, -7.67422020e-01,
       5.18340886e-01,  7.07096830e-02],
     [-4.51302677e-01,  2.79700905e-01, -1.63880944e-01,
      -1.38917759e-01, -4.43960607e-01]]],


   [[[ 3.17463160e-01, -5.04076332e-02, -8.81585240e-01,
      -1.82060301e-01, -2.36751184e-01],
     [ 2.67531663e-01,  2.18652248e-01, -1.66936445e+00,
      -5.63406110e-01, -5.56594372e-01],
     [ 7.96737373e-01, -2.78340966e-01, -2.50590038e+00,
      -4.65675175e-01, -7.91743040e-01],
     ...,
     [-7.95750767e-02, -6.24832958e-02, -1.17845392e+00,
      -3.42298150e-01, -4.55068082e-01],
     [-1.11248963e-01,  5.69165498e-03, -4.35324103e-01,
      -8.54895115e-02, -1.88251272e-01],
     [-1.50653318e-01,  1.27377361e-02,  1.51492655e-02,
       1.19028479e-01, -3.85457456e-01]],

    [[ 8.13371837e-02, -1.56518519e-01, -1.37296200e+00,
       4.02487218e-02, -1.08107239e-01],
     [ 4.26688671e-01, -1.59990668e-01, -2.07046509e+00,
      -3.27827781e-01, -2.51298040e-01],
     [ 1.19240952e+00, -3.20717335e-01, -2.48833346e+00,
      -3.72270435e-01, -4.60920751e-01],
     ...,
     [ 2.56346405e-01, -5.05646110e-01, -1.64647579e+00,
       4.12160903e-01, -5.44296741e-01],
     [ 7.94997364e-02,  2.68298060e-01, -7.36309409e-01,
       5.87890446e-01, -6.02420330e-01],
     [-1.83907256e-01, -9.35601294e-02, -2.63166338e-01,
       2.46009707e-01, -5.50730467e-01]],

    [[ 8.74397516e-01, -8.38985443e-02, -1.14052606e+00,
      -8.01209807e-01, -3.38738978e-01],
     [ 8.44795227e-01, -7.73854315e-01, -1.53216362e+00,
      -1.35623991e+00, -5.55843413e-01],
     [ 1.99087548e+00, -8.27039361e-01, -1.68097913e+00,
      -1.18121648e+00, -2.40117520e-01],
     ...,
     [-6.97122812e-02, -2.55597782e+00, -1.96200526e+00,
       9.07518983e-01, -7.67239273e-01],
     [ 5.37904501e-02, -1.47757912e+00, -8.45540464e-01,
       1.24326921e+00, -8.55075479e-01],
     [ 2.33911261e-01, -4.30901796e-01, -1.76986337e-01,
       8.89460027e-01, -7.61307478e-01]],

    ...,

    [[ 2.79194951e-01, -1.81278348e+00, -1.09550238e+00,
      -5.98862529e-01, -3.30086946e-01],
     [ 8.44225883e-02, -2.69907832e+00, -1.38061166e+00,
      -6.37267113e-01, -3.61868858e-01],
     [ 6.47942364e-01, -1.08203578e+00, -1.53872573e+00,
      -2.81839371e-01, -2.56620347e-01],
     ...,
     [ 1.50877178e+00, -3.95716637e-01, -5.07228494e-01,
       3.13638598e-01, -6.71119213e-01],
     [ 1.56054962e+00, -1.56519723e+00, -1.03512847e+00,
       2.58721173e-01, -1.41844809e+00],
     [ 7.66367912e-01, -3.13912213e-01, -4.77968872e-01,
       3.93721759e-01, -1.72142375e+00]],

    [[ 5.43866992e-01, -1.01636875e+00, -7.25057662e-01,
      -6.40807688e-01, -1.19497490e+00],
     [ 9.17642653e-01, -1.52718818e+00, -3.45820844e-01,
      -7.46625423e-01, -7.92670965e-01],
     [ 4.87573534e-01, -6.97847426e-01, -9.20011640e-01,
      -1.74273312e-01, -2.98590839e-01],
     ...,
     [ 8.93758833e-01,  9.63637173e-01, -9.69915628e-01,
      -2.18184501e-01, -1.47280300e+00],
     [ 6.52616501e-01, -2.35571459e-01, -1.15725541e+00,
       6.01388216e-01, -1.84936476e+00],
     [ 8.90739441e-01, -3.74376893e-01, -9.68227923e-01,
       2.58575439e-01, -1.72229290e+00]],

    [[ 3.02774817e-01, -4.74457115e-01, -1.17102958e-01,
      -3.94638985e-01, -1.22509646e+00],
     [ 3.82876813e-01, -9.90539908e-01, -9.44921672e-02,
      -1.08406916e-01, -9.80609477e-01],
     [ 6.28874183e-01,  2.03131840e-01, -3.57589692e-01,
       1.06400937e-01, -5.42568922e-01],
     ...,
     [ 8.73160362e-01,  3.72517824e-01, -1.21485269e+00,
       2.38574207e-01, -1.56600475e+00],
     [ 8.11879039e-01, -1.22650057e-01, -7.50864446e-01,
       4.96826828e-01, -1.29960561e+00],
     [ 7.67562211e-01,  4.83283401e-02, -6.67566299e-01,
       2.28160113e-01, -1.28627563e+00]]]], dtype=float32)


这些数字是什么意思,我如何使它们看起来像正常概率?

附言projections.shape给出(8,8,8,5)作为输出。不确定这意味着什么,但是如果有帮助,我很高兴。

最佳答案

我认为您的问题在于这条线

x = Dense(5, name='prediction')(xception.output)


您尚未设置激活功能。尝试:

x = Dense(5, activation='softmax', name='prediction')(xception.output)

09-30 18:22