reset all weights tensorflow

Solutions on MaxInterview for reset all weights tensorflow by the best coders in the world

showing results for - "reset all weights tensorflow"
Anna
03 Jan 2021
1for layer in model.layers: 
2  if isinstance(layer, tf.keras.Model):
3  reset_weights(layer)
4    continue
5    for k, initializer in layer.__dict__.items():
6  if "initializer" not in k:
7  continue
8    # find the corresponding variable
9    var = getattr(layer, k.replace("_initializer", ""))
10    var.assign(initializer(var.shape, var.dtype))