我是Keras的新手,正在建立模型。我想在训练前几层时冻结模型最后几层的权重。我试图将横向模型的可训练属性设置为False,但似乎不起作用。这是代码和模型摘要:
opt = optimizers.Adam(1e-3)
domain_layers = self._build_domain_regressor()
domain_layers.trainble = False
feature_extrator = self._build_common()
img_inputs = Input(shape=(160, 160, 3))
conv_out = feature_extrator(img_inputs)
domain_label = domain_layers(conv_out)
self.domain_regressor = Model(img_inputs, domain_label)
self.domain_regressor.compile(optimizer = opt, loss='binary_crossentropy', metrics=['accuracy'])
self.domain_regressor.summary()
Run Code Online (Sandbox Code Playgroud)
模型摘要:模型摘要。
如您所见,model_1是可训练的。但是根据代码,它被设置为不可训练。