autokeras icon indicating copy to clipboard operation
autokeras copied to clipboard

Layer names duplicated with multiple image inputs

Open simoncozens opened this issue 4 years ago • 6 comments

Bug Description

When multiple ImageBlocks are used in the same model, the layer names they generate are not unique, so the model does not build.

Bug Reproduction

input_node1 = ak.ImageInput()
input_node2 = ak.ImageInput()
output_node1 = ak.ImageBlock(augment=False)(input_node1)
output_node2 = ak.ImageBlock(augment=False)(input_node2)
merged = ak.Merge()([output_node1, output_node2])
output_node = ak.ClassificationHead()(merged)
clf = ak.AutoModel(
    inputs=[input_node1, input_node2],
    outputs=output_node,
    overwrite=True,
    max_trials=5)

Expected Behavior

The model should build. Instead:

ValueError: The name "conv1_pad" is used 2 times in the model. All layer names should be unique.

Setup Details

Include the details about the versions of:

  • OS type and version: Colab
  • Python: 3.6
  • autokeras: 1.0.3
  • keras-tuner: 1.0.2rc0
  • scikit-learn: 0.22.2.post1
  • numpy: 1.18.5
  • pandas: 1.0.5
  • tensorflow: 2.2.0

simoncozens avatar Jul 09 '20 08:07 simoncozens

Is there any update on this issue ? I'm facing the same problem as well

rakshith291 avatar Nov 16 '20 15:11 rakshith291

Also interested in this issue - and is it applicable to other block types as well?

Unemyr avatar Nov 30 '20 15:11 Unemyr

Renaming the layers in the following way solved the problem for me.

for layer in model_con_1.layers : layer._name = layer.name + str('_1') for layer in model_con_2.layers : layer._name = layer.name + str('_2')

rakshith291 avatar Jan 07 '21 17:01 rakshith291

Any update? I'm facing this problem trying to create an AutoModel with multiple ImageInputs

vecrvecr avatar Mar 26 '21 09:03 vecrvecr

Bump on this one. Is it possible to use multiple image inputs with AutoModel? I see that rakshith291 posted some code to rename layers, but where does that go, somewhere in the source of the fit function?

abe-martin avatar Mar 07 '22 23:03 abe-martin

same issue, I have tried to change autokeras _convert_to_dataset function but not work

EmberaThomas avatar Dec 22 '23 09:12 EmberaThomas