Ошибка при проверке цели: ожидаемый результат будет иметь shape (10,), но получил массив с shape (1,) - PullRequest
0 голосов
/ 05 апреля 2020

Я пытаюсь реализовать модель Inception в Google colab, и когда я запускаю model.fit, я получаю эту ошибку. Кто-нибудь может мне помочь?

ValueError                                Traceback (most recent call last)
<ipython-input-25-b030aa96e908> in <module>()
      4                     batch_size=256,
      5                     epochs=epochs,
----> 6                     callbacks=[lr_sc])

2 frames
/usr/local/lib/python3.6/dist-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
    139                             ': expected ' + names[i] + ' to have shape ' +
    140                             str(shape) + ' but got array with shape ' +
--> 141                             str(data_shape))
    142     return data
    143 

ValueError: Error when checking target: expected output to have shape (10,) but got array with shape (1,)

Мой код здесь:

epochs = 25
initial_lrate = 0.001

def decay(epoch, steps=100):
    initial_lrate = 0.001
    drop = 0.96
    epochs_drop = 8
    lrate = initial_lrate * math.pow(drop, math.floor((1+epoch)/epochs_drop))
    return lrate

sgd = SGD(lr=initial_lrate, momentum=0.9, nesterov=False)

lr_sc = LearningRateScheduler(decay, verbose=1)

model.compile(loss=['categorical_crossentropy', 'categorical_crossentropy', 'categorical_crossentropy'], loss_weights=[1, 0.3, 0.3], optimizer=sgd, metrics=['accuracy'])

И модель. Подходит здесь:

history = model.fit(X_train, 
                    [y_train, y_train, y_train], 
                    validation_data=(X_test, [y_test, y_test, y_test]), 
                    batch_size=256, 
                    epochs=epochs, 
                    callbacks=[lr_sc])
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...