摘要: 注意点: torch.nn.CrossEntropyLoss中的ignore index 是作用在target上 torch.nn.CrossEntropyLoss 最终交叉熵的值是平均值 统计平均值的时候,不会统计ignore index的 公式中的值是以自然数e为底 对于 C 类分类任务,交叉熵 阅读全文
posted @ 2025-03-24 21:14 xiezhengcai 阅读(159) 评论(0) 推荐(0)
摘要: ![](https://img2024.cnblogs.com/blog/369406/202503/369406-20250324210103633-1540745538.png) ![](https://img2024.cnblogs.com/blog/369406/202503/369406-20250324210141040-419718486.png) ![](https://img20 阅读全文
posted @ 2025-03-24 21:03 xiezhengcai 阅读(23) 评论(0) 推荐(0)
摘要: PyTorch 默认行为:nn.Linear 的权重默认使用 Kaiming 均匀分布(mode='fan_in', nonlinearity='relu'),偏置初始化为 0。 阅读全文
posted @ 2025-03-24 20:55 xiezhengcai 阅读(114) 评论(0) 推荐(0)
摘要: 将数据压平 通过 nn.Linear(cfg.in_feature, cfg.expert_num) 得到专家权重 通过 torch.topk 得到 每个top上的权重,以及 以专家索引为value的 专家 (batch_size*seq_len,top_k) , 它表示每个token在不同top_ 阅读全文
posted @ 2025-03-24 17:16 xiezhengcai 阅读(34) 评论(0) 推荐(0)