我正在尝试根据图像和文本对产品进行分类,但遇到错误
img_width, img_height = 224, 224
# build the VGG16 network
model = Sequential()
model.add(ZeroPadding2D((1, 1), input_shape=(img_width, img_height,3), name='image_input'))
model.add(Convolution2D(64, (3, 3), activation='relu', name='conv1_1'))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(64, (3, 3), activation='relu', name='conv1_2'))
model.add(MaxPooling2D((2, 2), strides=(2, 2)))
# set trainable to false in all layers
for layer in model.layers:
if hasattr(layer, 'trainable'):
layer.trainable = False
return model
WEIGHTS_PATH='E:/'
weight_file = ''.join((WEIGHTS_PATH, '/vgg16_weights.h5'))
f = h5py.File(weight_file,mode='r')
for k in range(f.attrs['nb_layers']):
if k >= len(model.layers):
# we don't look at the last (fully-connected) layers …Run Code Online (Sandbox Code Playgroud)