问题
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