此代码:
input_tensor = Input(shape=(input_width, input_height, 3))
ResNet50 = ResNet50(include_top=False, weights='imagenet',input_tensor=input_tensor)
top_model = Sequential()
top_model.add(Flatten(input_shape=ResNet50.output_shape[1:]))
top_model.add(Dense(8, activation='softmax'))
model = Model(input=ResNet50.input, output=top_model(ResNet50.output))
model.compile(loss='categorical_crossentropy',
optimizer=optimizers.SGD(lr=1e-3, momentum=0.9),
metrics=['accuracy'])
导致TypeError
:
TypeError Traceback (most recent call last)
<ipython-input-41-07033765de09> in <module>()
58 top_model.add(Flatten(input_shape=ResNet50.output_shape[1:]))
59 top_model.add(Dense(8, activation='softmax'))
---> 60 model = Model(input=ResNet50.input, output=top_model(ResNet50.output))
61 model.compile(loss='categorical_crossentropy',
62 optimizer=optimizers.SGD(lr=1e-3, momentum=0.9),
2 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/generic_utils.py in validate_kwargs(kwargs, allowed_kwargs, error_message)
776 for kwarg in kwargs:
777 if kwarg not in allowed_kwargs:
--> 778 raise TypeError(error_message, kwarg)
779
780
TypeError: ('Keyword argument not understood:', 'input')
我应该如何解决?
答案 0 :(得分:0)
正如史努比博士在评论中提到的那样,这些参数称为“输入”和“输出”,并带有“ s”:
model = Model(inputs=inputs, outputs=x)