Skip to content

Instantly share code, notes, and snippets.

@elijahc
Created April 13, 2018 18:27
Show Gist options
  • Select an option

  • Save elijahc/eabbe365b3b2ba468d33be97e788fec8 to your computer and use it in GitHub Desktop.

Select an option

Save elijahc/eabbe365b3b2ba468d33be97e788fec8 to your computer and use it in GitHub Desktop.
Reset weights in a Keras layer
import keras.backend as K
def reset_weights(model):
session = K.get_session()
for layer in model.layers:
if hasattr(layer, 'kernel_initializer'):
layer.kernel.initializer.run(session=session)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment