【发布时间】:2020-04-21 22:14:43
【问题描述】:
这行得通:
img = Input(shape=(224,224,3))
efnet = EfficientNetB0(
weights = 'noisy-student',
include_top = False,
pooling = None,
classes = None
)
for layer in efnet.layers:
layer.trainable = False
x = efnet(img)
# ... any number of layers ...
x = Dense(1)(x)
model = Model(inputs=img, outputs=x)
这没有(“图表断开”):
img = Input(shape=(224,224,3))
img = Dropout(0.2)(img)
# ^ "Preprocessing" could be anything, Dropout is a simple example
efnet = EfficientNetB0(
weights = 'noisy-student',
include_top = False,
pooling = None,
classes = None
)
for layer in efnet.layers:
layer.trainable = False
x = efnet(img)
# ... any number of layers ...
x = Dense(1)(x)
model = Model(inputs=img, outputs=x)
两者之间的唯一区别是“预处理”。为什么这不起作用,以及如何在输入和“模型即层”之间放置中间层,如上所示?
(在 efnet 声明中指定 input_shape 和/或 input_tensor 无效。事实上,指定 input_tensor 会神秘地导致 efnet 权重无法加载,因为 efnet 显然有 131 层 (???) 而不是预计 130。)
【问题讨论】:
-
你从哪里得到
EfficientNetB0? -
第二个代码对我来说看起来不错。您确定问题不在其他地方,例如
efnet和Dense之间的层? -
@today 我敢肯定。 efnet 和 Dense 之间没有层。 (可能有,但没有。)
-
@thushv89 "$ pip installefficientnet" 和 "从efficientnet.keras import EfficientNetB0"
-
你在使用
tf.keras吗?如果是这样,请改用import efficientnet.tfkeras。
标签: python tensorflow keras graph model