【问题标题】:TypeError: ('Keyword argument not understood:', 'input') of ResNetResNet的TypeError:('关键字参数不理解:','输入')
【发布时间】:2021-01-30 04:52:40
【问题描述】:

这段代码:

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')

我应该如何解决它?

  • 张量流版本:2.3.0
  • keras 版本:2.4.3

【问题讨论】:

  • 参数称为输入和输出
  • @Dr.Snoopy 我理解不正确。什么意思?

标签: tensorflow keras tensorflow2.0 tf.keras resnet


【解决方案1】:

正如 Snoopy 博士在评论中提到的,参数称为“输入”和“输出”,带有“s”:

model = Model(inputs=inputs, outputs=x)

【讨论】:

    猜你喜欢
    • 2020-12-09
    • 2020-12-09
    • 1970-01-01
    • 2021-08-17
    • 1970-01-01
    • 2018-12-29
    • 2021-01-28
    • 1970-01-01
    相关资源
    最近更新 更多