Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bandiatindra/0d8cf46796275a99b607d1728fda3973 to your computer and use it in GitHub Desktop.
Save bandiatindra/0d8cf46796275a99b607d1728fda3973 to your computer and use it in GitHub Desktop.
# Taking the last convolutional layer
layer = model.layers[-4]
weights = layer.get_weights()
# Randomly initializing the weights of the last layer
new_kernel = np.random.normal(size=weights[0].shape)/(GRID_H*GRID_W)
new_bias = np.random.normal(size=weights[1].shape)/(GRID_H*GRID_W)
# Setting the weights of the last layer
layer.set_weights([new_kernel, new_bias])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment