Issue
Code:
config = MCM_feature_extractor.get_layer(index=132).get_config()
x = tf.keras.layers.Layer()
x = x.from_config(config)
config:
{'axis': ListWrapper([3]),
'beta_constraint': None,
'beta_initializer': {'class_name': 'Zeros', 'config': {}},
'beta_regularizer': None,
'center': True,
'dtype': 'float32',
'epsilon': 1.001e-05,
'gamma_constraint': None,
'gamma_initializer': {'class_name': 'Ones', 'config': {}},
'gamma_regularizer': None,
'momentum': 0.99,
'moving_mean_initializer': {'class_name': 'Zeros', 'config': {}},
'moving_variance_initializer': {'class_name': 'Ones', 'config': {}},
'name': 'conv4_block5_preact_bn',
'scale': True,
'trainable': True}
Am i doing it properly? i want to copy a few layers from the MCM model and use them to create another model using the functional API, then copy the weights.
Solution
Solution:
layer = MCM_feature_extractor.get_layer(index=132)
config = layer.get_config()
weights = layer.get_weights()
config['name'] = layer.name+'_2'
second_layer = type(layer).from_config(config)
second_layer.build(layer.input_shape)
second_layer.set_weights(weights)
second_layer = second_layer(title_input)
Answered By - Luciano Dourado
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.