检查目标时出错:预期dense_2具有形状(无,256)但是具有形状的数组(16210,4096)

时间:2017-12-18 17:19:05

标签: tensorflow keras

我在Keras 2.1.2中尝试训练我的模型时遇到了问题 ,Python 3.6.0和Tensorflow 1.3.0后端

ValueError: Error when checking target: expected dense_2 to have shape (None, 256) but got array with shape (16210, 4096)
    model.add(
        Conv2D(
            nb_filters_1, filter_size_1,
            filter_size_1, subsample=stride_1,
            input_shape=(patch_size, patch_size, num_channels), kernel_initializer='glorot_uniform', activation='relu'))
    model.add(MaxPooling2D(pool_size=pool_size_1))
    model.add(
        Conv2D(
            nb_filters_2, filter_size_2,
            filter_size_2, subsample=stride_2, activation='relu'))
    #model.add(Activation('relu'))
    model.add(
        Conv2D(
            nb_filters_3, filter_size_3,
            filter_size_3, subsample=stride_3, activation='relu'))
    #model.add(Activation('relu'))
    model.add(Flatten())
    model.add(Dense(4096, activation='relu'))
    model.add(Dense(256, activation='sigmoid'))

我浏览了所有相关问题但没有解决我的问题。请帮忙。

0 个答案:

没有答案