4

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?

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
WKK
  • 159
  • 2
  • 13

1 Answers1

8

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

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
Lau
  • 1,353
  • 7
  • 26