会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
無名
大猫咪与小狮子
管理
上一页
1
2
3
4
5
6
7
8
···
12
下一页
2025年3月14日
torch.where 的详细用法
摘要: torch.where 会根据条件去选择元素,返回一个tensor。¶ torch.where(condition, input, other, *, out=None) → Tensor condition 是一个BoolTensor input 和 other 可以常量,也可以是张量, 返回的张
阅读全文
posted @ 2025-03-14 12:10 xiezhengcai
阅读(490)
评论(0)
推荐(0)
2025年3月12日
pytorch 各个组件
摘要: nn.Embedding 本质上是可学习的查找表 一个简单的 Python 字典(查找表)
阅读全文
posted @ 2025-03-12 18:08 xiezhengcai
阅读(4)
评论(0)
推荐(0)
pytorch 中常用张量操作api介绍
摘要: Tensor的创建¶ 从list和元组及numpy中创建¶ torch.tensor 可以从元组,list,以及 numpy 数组中创建张量 In [3]: importtorch importnumpyasnp fromIPython.core.interactiveshellimport Int
阅读全文
posted @ 2025-03-12 16:50 xiezhengcai
阅读(50)
评论(0)
推荐(0)
2025年3月10日
transformer 中的掩码类型
摘要: 掩码矩阵为 True, False 格式
阅读全文
posted @ 2025-03-10 19:29 xiezhengcai
阅读(15)
评论(0)
推荐(0)
Transfomer 中的强制教学(Teacher Forcing)
摘要: 在预测阶段, 我们希望输入 "天雷滚滚我好怕怕" 和 "[cls]" 能预测出下一个token: 劈 于是我们在训练阶段,我们的输入是 "天雷滚滚我好怕怕" 和 “[cls]劈得我浑身掉渣渣”, 由于我们希望"[cls]" 能预测出 “劈” 字。 我们在损失函数计算的入参设置为: "劈得我浑身掉渣渣
阅读全文
posted @ 2025-03-10 14:16 xiezhengcai
阅读(181)
评论(0)
推荐(0)
2025年3月9日
transformer中带掩码的多头注意力理解
摘要: 解码器在做多头注意力的掩码时候, 得到的相似度矩阵 相似度矩阵A A = Q@KT : [batch_size,n_head,seq_len,seq_len] 第一个为Q的seq_len,第二个为K的seq_len 对A做因果掩码 生成下三角掩码矩阵: M: [seq_len,seq_len] 将该
阅读全文
posted @ 2025-03-09 23:39 xiezhengcai
阅读(161)
评论(0)
推荐(0)
transformer中每个阶段的张量形状
摘要: 通用部分 批次数量: batch_size 句子长度:seq_len 模型维度:d_model 多头头数:n_head 词典总数:vocab_num 输入时: input_ids : [batch_size,seq_len] input_mask: [batch_size,seq_len] targ
阅读全文
posted @ 2025-03-09 23:22 xiezhengcai
阅读(76)
评论(0)
推荐(0)
损失函数的入参形状
摘要: # 假设 logits 形状 [1,3,5], logits = torch.randn(1, 3, 5) targets = torch.tensor([[1, 2, 1, 1, 2]]) # 形状为 [1,5] loss_fn = nn.CrossEntropyLoss() loss = los
阅读全文
posted @ 2025-03-09 11:48 xiezhengcai
阅读(12)
评论(0)
推荐(0)
2025年3月8日
张量的索引
摘要: 整数列表选择 x = torch.tensor([[[10, 20, 30], [40, 50, 60]]]) x1 = x[[0, 0]] x2 = x[[0, 0], [0, 1]] x3 = x[0, [0, 1], [0, 1]] print(x1) print(x2) print(x3)
阅读全文
posted @ 2025-03-08 19:23 xiezhengcai
阅读(18)
评论(0)
推荐(0)
2023年12月10日
cs ip,ds,ss sp
摘要: cs和ip寄存器不能直接修改,需要使用转移指令。 ds寄存器不能使用一个数值直接送入段寄存器,需要使用一个通用寄存器做中转, ss寄存器同ds寄存器。 sp寄存器可以直接修改。 综上,段相关寄存器都需需要中转。 cs ip 寄存器需要转移指令。
阅读全文
posted @ 2023-12-10 13:26 xiezhengcai
阅读(89)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
···
12
下一页
公告