gpt4 book ai didi

python - Tensorflow2.0 Keras : Is dropout disabled during testing by default?

转载 作者:行者123 更新时间:2023-12-03 23:10:46 25 4
gpt4 key购买 nike

我想知道在以下模型中,当我调用 model.evaluate(...). 时是否会禁用 dropout

layers = [tf.keras.layers.Dense(size, activation='relu')
for size in (20, 40, 20)]
layers.insert(1, tf.keras.layers.Dropout(0.2))
layers.append(tf.keras.layers.Dense(1, activation="sigmoid"))
model = tf.keras.models.Sequential(layers)
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),
loss=tf.keras.losses.BinaryCrossentropy())
model.fit(...)
model.evaluate(...) #==> will dropout be deactivated here?

最佳答案

是的,在推理时始终禁用 dropout ( evaluate/predict )。

关于python - Tensorflow2.0 Keras : Is dropout disabled during testing by default?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57808266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com