Keras rename model and layers

前端 未结 8 803
情话喂你
情话喂你 2020-12-31 00:46

1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script. Class Model seem to have the property model.name, but whe

相关标签:
8条回答
  • 2020-12-31 01:21

    To rename a keras model in TF2.2.0:

    model._name = "newname"

    I have no idea if this is a bad idea - they don't seem to want you to do it, but it does work. To confirm, call model.summary() and you should see the new name.

    0 讨论(0)
  • 2020-12-31 01:24

    To change only one layer name in a model you can use the following lines:

    my_model.layers[0]._name = 'my_new_name_for_the_first_layer'
    my_model.layers[1]._name = 'my_new_name_for_the_second_layer'
    my_model.layers[-1]._name = 'my_new_name_for_the_last_layer'
    
    0 讨论(0)
提交回复
热议问题