Answers for "reset all weights keras"

0

reset all weights keras

for layer in model.layers: 
    if isinstance(layer, tf.keras.Model):
      reset_weights(layer)
      continue
    for k, initializer in layer.__dict__.items():
      if "initializer" not in k:
        continue
      # find the corresponding variable
      var = getattr(layer, k.replace("_initializer", ""))
      var.assign(initializer(var.shape, var.dtype))
Posted by: Guest on August-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language