You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Keras Dropout实际执行机制探究:TensorFlow如何生成批量独立掩码?

Keras Dropout层掩码生成逻辑疑问
  • 我正在研究K.layers.Dropout的实现,根据文献描述,它会为每个元素独立采样0/1掩码。
  • 但关闭Eager Execution后,TensorFlow进入图模式,此时无法获取样本的具体维度——比如运行以下代码时,inputs.shape的第一维度会显示为None:
class CustomLayer(K.keras.Layer):
    def call(self, inputs):
        tf.print(inputs.shape)
  • 我想知道TensorFlow是如何为批量中的每个样本生成独立掩码的?我猜测它可能通过tf.vectorized_map实现高效的逐元素随机掩码生成。

内容的提问来源于stack exchange,提问作者Alberto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 20:46:04