![](https://cocoinit23.com/wp-content/uploads/2019/03/fdasertwadfsz-300x169.png)
Kerasで同じモデルを複数使った時に表題のエラー。
model1 = vgg16.VGG16(...)
model2 = vgg16.VGG16(...)
みたいなコードを書いていたら、
RuntimeError: The name is used 2 times in the model.All layer names should be unique.
名前を変えないとダメらしい。
model1.name = 'vgg1'
model2.name = 'vgg2'
今度は別のエラー。
AttributeError: Can't set the attribute "name", likely because it conflicts with an existing read-only @property of the object. Please choose a different name.
name属性はread-onlyになっているらしい。
_nameというアンダーバー付きの隠し属性を設定して回避する。
model1._name = 'vgg1'
model2._name = 'vgg2'
これで解決。
参考
![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a)
Keras - All layer names should be unique
I combine two VGG net in keras together to make classification task. When I run the program, it shows an error: RuntimeE...
![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a)
Error when trying to rename a pretrained model on tf.keras
I trained two models in order to ensemble them, when I try to load them with this code: from tensorflow.keras.models imp...
![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a)
Keras rename model and layers
1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script. Clas...
コメント