如何在Keras中设置内核初始化程序(glorot_uniform)的种子值 [英] How to set seed value of kernel initializer (glorot_uniform) in Keras
本文介绍了如何在Keras中设置内核初始化程序(glorot_uniform)的种子值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Keras中设置glorot_uniform内核初始化程序的种子值.
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)
如果我如下删除(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.
如何设置种子值?
推荐答案
Keras可以将字符串和函数用作初始化程序的参数.这些字符串仅使用初始化程序的默认选项. 为您的FC层尝试以下代码:
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)))
这里您具有初始化程序的文档: https://keras.io/initializers
Here you have the documentation for the initializers: https://keras.io/initializers
这篇关于如何在Keras中设置内核初始化程序(glorot_uniform)的种子值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文