【问题标题】:input shape error train some data with resnet keras输入形状错误用 resnet keras 训练一些数据
【发布时间】:2017-12-29 14:21:05
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

  • 如果答案解决了您的问题,请接受(答案会占用受访者宝贵的时间)

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


【解决方案1】:

这只是一个错字,您的训练数据具有形状(样本,99,81,1),因此输入形状应该是(99,81,1),而不是(98,81,1)。差了一个。

【讨论】:

    猜你喜欢
    • 2021-01-24
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-20
    • 2017-10-15
    • 1970-01-01
    相关资源
    最近更新 更多