Skip to content

Instantly share code, notes, and snippets.

@lukedeo
Last active March 7, 2016 18:31
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 lukedeo/c7d9632d78e1dd471718 to your computer and use it in GitHub Desktop.
Save lukedeo/c7d9632d78e1dd471718 to your computer and use it in GitHub Desktop.
Custom initializer for Keras
import keras.backend as K
import numpy as np
def custom_uniform(shape, range=(-1, 1), name=None):
min_, max_ = range
return K.variable(np.random.uniform(low=min_, high=max_, size=shape), name=name)
net.add(Dense(10, input_dim=5, init=lambda shape, name: custom_uniform(shape, (-10, 5), name)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment