[英]Does setting the seed in tf.random.set_seed also set the seed used by the glorot_uniform kernel_initializer when using a conv2D layer in keras?
[英]Keras - Glorot uniform initializer: input and output unit?
Keras文檔中有幾件事我不理解
它從
-limit, limit
內的均勻分布中抽取樣本-limit, limit
限制為sqrt(6 / (fan_in + fan_out))
,其中fan_in
是權重張量中的輸入單位數,而fan_out
是權重張量中的輸出單位數。
在哪里可以看到模型的fan_in
和fan_out
? 這是我的模型:
model = Sequential() model.add(Flatten(input_shape=(224,224,3))) model.add(Dense(256, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(1, activation='sigmoid'))
使用model.summary()
,您將看到每層的input
和output
形狀,這就是Glorot統一初始化 fan_out
分別用於fan_in
和fan_out
。
你的例子 :
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
flatten_1 (Flatten) (None, 150528) 0
_________________________________________________________________
dense_1 (Dense) (None, 256) 38535424
_________________________________________________________________
dropout_1 (Dropout) (None, 256) 0
_________________________________________________________________
dense_2 (Dense) (None, 1) 257
=================================================================
因此dense_1
fan_in
等於150528(輸入),而fan_out
256(輸出)。 dense_2
在另一方面將具有fan_in
256(從以前的致密層輸入)和fan_out
1(它的輸出形狀)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.