输入形状错误用resnet keras训练一些数据

时间:2017-12-29 14:21:05

标签: neural-network keras conv-neural-network resnet

我正在尝试用CNN训练一些数据。

   x_train.shape
    (67197, 99, 81, 1)
   y_train.shape
    (67197, 12)

尝试使用Keras的Resnet方法

import keras
import keras_resnet.models

input_shape = (98,81,1)
nclass = 12

    x = keras.layers.Input(input_shape)
    model = keras_resnet.models.ResNet50(x,classes=nclass)
    model.compile("adam","categorical_crossentropy",["accuracy"])
    model.fit(x_train,y_train,
             batch_size = 300,
             nb_epoch=5,
             validation_data = (x_test,y_test),
             shuffle = True,
             )

但是我遇到了一些形状错误。

ValueError: Error when checking input: expected input_3 to have shape (None, 98, 81, 1) but got array with shape (67197, 99, 81, 1)

1 个答案:

答案 0 :(得分:0)

它只是一个错字,你的训练数据有形状(样本,99,81,1),所以输入形状应该是(99,81,1),而不是(98,81,1)。它只是一个人。