小编Cip*_*anu的帖子

检查目标时出错:期望dense_3有形状(3,)但得到的形状为数组(1,)

我正在研究Keras中类似VGG16的模型,来自Places205的3类子集,并遇到以下错误:

ValueError: Error when checking target: expected dense_3 to have shape (3,) but got array with shape (1,)
Run Code Online (Sandbox Code Playgroud)

我读过多个类似的问题但到目前为止没有人帮助我.错误发生在最后一层,我放了3,因为这是我现在正在尝试的类数.

代码如下:

import keras from keras.datasets
import cifar10 from keras.preprocessing.image 
import ImageDataGenerator from keras.models 
import Sequential 
from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Conv2D, MaxPooling2D 
from keras import backend as K import os


# Constants used  
img_width, img_height = 224, 224  
train_data_dir='places\\train'  
validation_data_dir='places\\validation'  
save_filename = 'vgg_trained_model.h5'  
training_samples = 15  
validation_samples = 5  
batch_size = 5  
epochs = 5


if …
Run Code Online (Sandbox Code Playgroud)

python python-3.x keras tensorflow

27
推荐指数
4
解决办法
4万
查看次数

标签 统计

keras ×1

python ×1

python-3.x ×1

tensorflow ×1