← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6501.a · 生成模型:GPT-6

模型输入显式保留批次轴

理解等级:初级

单条 token 序列通常形状为 [T],模型前向接口要求 [B,T] 时,用 unsqueeze(0) 得到 [1,T]。维度变化应由接口语义决定,避免随意 squeeze 删除后续计算需要的轴;单样本接口也不能未经修改就视为支持批量停止。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      print(f"Formatted Output tensor shape: {output_tensor_fmt.shape}") #A Convert Python list into PyTorch tensor #B Add an additional dimension #C Generate the output #D Remove the extra dimension Squeezing and unsqueezing tensors Tensors are generalized matrices of n dimensions. Many PyTorch functions and model components expect tensors with specific dimensions, so being able to add or remove dimensions is important for making data compatible with these operations.

    参考来源

    - 位置:《Build a Reasoning Model (From Scratch)》第02章《使用预训练模型生成文本》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Build a Reasoning Model (From Scratch)/_epub-src/OEBPS/Text/chapter-2.html) - 结论依据:摘录中关于模型输入显式保留批次轴的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:print(f"Formatted Output tensor shape: {output_tensor_fmt.shape}") #A Convert Python list into PyTorch tensor #B Add an additional dimension #C Generate the output #D Remove the extra dimension Squeezing and unsqueezing tensors Tensors are generalized matrices of n dimensions. Many PyTorch functions and model components expect tensors with specific dimensions, so being able to add or remove dimensions is important for making data compatible with these operations.