-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This may be a basic question, but what is the recommended way to use Keras when I need to do some modifications to it? #374
Comments
You can define your custom function as Theano function and pass it to model. See my answer in #369 for objective function case. I think it's same for initialization function. |
Is it really same? Here is the code that gets executed on the value of init parameter:
It seems that the value must be a string rather than a function, isn't it? |
I did it like the following, please let me know if there is a better method!
|
Did you see the inside of the So this works and I verified it. import theano
import theano.tensor as T
from keras.utils.theano_utils import sharedX
def custom_initialization(shape, scale=0.05):
'''just another normal'''
return sharedX(np.random.randn(*shape) * scale)
model = Sequential()
model.add(Convolution2D(32, 1, 3, 3, border_mode='full', init=custom_initialization)) |
Ah, I see. Looks very nice! |
For example, suppose I want to use keras, but I want to try a different weight initialization method, which is not included in keras. How am I supposed to use Keras in this case (without modifying the source code of keras itself) ?
The text was updated successfully, but these errors were encountered: