← 返回卡片

原书出处

深入浅出Embedding:原理解析与应用实践 (吴茂贵, 王红星)

12 第12章 用Transformer实现英译中

核验版本的摘录快照 · 导入于 2026-11-19T04:48:36.602Z

视为1,其余为0 mask = tf.math.logical_not(tf.math.equal(real, 0))

# 计算所有位置的交叉熵,但不汇总 loss_ = loss_object(real, pred) mask = tf.cast(mask, dtype=loss_.dtype) loss_ *= mask

# 只计算非<pad> 位置的损失 return tf.reduce_mean(loss_) 3. 定义两个评估指标

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/深入浅出Embedding:原理解析与应用实践 (吴茂贵, 王红星)/_epub-src/OEBPS/Text/Chapter16_0004.xhtml

EPUB SHA-256:0056cad2f11cb1d60ead5054060bd6d41fef87dd049656db310bdc789c0ec7da