I want to build a neural network that has two inputs and uses EfficientNetB1 to extract features and fine-tune on new layers, so I wrote this code:
def createNet(self,shape):
FE1 = K.applications.EfficientNetB1(include_top=False, input_shape=shape)
FE2 = K.applications.EfficientNetB1(include_top=False, input_shape=shape)
inp1 = FE1.input
out1 = FE1.layers[-1].output
inp2 = FE2.input
out2 = FE2.layers[-1].output
merged_out = K.layers.concatenate((out1, out2))
# .... other layers
self.model = K.models.Model(inputs=[inp1, inp2], outputs=[merged_out])
self.model.summary()
But I got this error:
ValueError: The name "stem_conv_pad" is used 2 times in the model. All layer names should be unique.
So how can I build my model?
Base on this I added below codes to solve it.
for layer in FE2.layers:
layer._name = layer.name + str("_2")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.