How to set seed value of kernel initializer (glorot_uniform) in Keras

依然范特西╮ 提交于 2019-12-24 00:54:56

问题


I'd like to set seed value of glorot_uniform kernel initializer in Keras.

model.add(Dense(50, input_dim=self.state_size, activation='relu', kernel_initializer='glorot_uniform(seed=0)'))

When I use above code, error message is below.

ValueError: Unknown initializer: glorot_uniform(seed=0)

If I remove "(seed=0)" like as below

 model.add(Dense(50, input_dim=self.state_size, activation='relu', kernel_initializer='glorot_uniform'))

It works well without setting a seed value.

How can I set a seed value?


回答1:


Keras can use strings and functions as arguments for initilizers. The strings just use the default options for initializers. Try this line of code for your FC layer:

from keras import initializers
model.add(Dense(50, input_dim=self.state_size, activation='relu', kernel_initializer=initializers.glorot_uniform(seed=0)))

Here you have the documentation for the initializers: https://keras.io/initializers



来源:https://stackoverflow.com/questions/50733569/how-to-set-seed-value-of-kernel-initializer-glorot-uniform-in-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!