tensor补充

文章目录

矩阵*运算

python 复制代码
import torch
b = torch.arange(0,5000).unsqueeze(-1)
'''
tensor([[   0],
        [   1],
        [   2],
        ...,
        [4997],
        [4998],
        [4999]])
'''
a = torch.arange(0,128,2)
'''
tensor([  0,   2,   4,   6,   8,  10,  12,  14,  16,  18,  20,  22,  24,  26,
         28,  30,  32,  34,  36,  38,  40,  42,  44,  46,  48,  50,  52,  54,
         56,  58,  60,  62,  64,  66,  68,  70,  72,  74,  76,  78,  80,  82,
         84,  86,  88,  90,  92,  94,  96,  98, 100, 102, 104, 106, 108, 110,
        112, 114, 116, 118, 120, 122, 124, 126])
'''

c = b * a

'''
tensor([[     0,      0,      0,  ...,      0,      0,      0],
        [     0,      2,      4,  ...,    122,    124,    126],
        [     0,      4,      8,  ...,    244,    248,    252],
        ...,
        [     0,   9994,  19988,  ..., 609634, 619628, 629622],
        [     0,   9996,  19992,  ..., 609756, 619752, 629748],
        [     0,   9998,  19996,  ..., 609878, 619876, 629874]])
'''
相关推荐
垚森16 小时前
我用 GLM-5.2 造了个炸裂主题后台:16 套主题随心切,可在线体验
ai·react
doiito20 小时前
【Agent Harness】Gliding Horse 工具结果压缩体系:如何用“指针”驯服上下文膨胀
ai·rust·架构设计·系统设计·ai agent
weiwei228441 天前
神经网络模型导出及开放标准格式ONNX
pytorch·onnx
doiito2 天前
【Agent Harness】Gliding Horse 上下文动态感知与智能压缩:让 Agent 真正“听得进”每一句话
ai·rust·架构设计·系统设计·ai agent
探索云原生3 天前
K8s 1.36 这个 GA 特性,把 initContainer 拉模型的 hack 干掉了
ai·云原生·kubernetes
Zy宇3 天前
从养 OpenClaw 到养社区 AI:一套 Multi-Agent 社区的设计思路
人工智能·ai
doiito3 天前
【Agent Harness】Gliding Horse 记忆系统深度剖析:像 CPU 一样思考的 AI 记忆架构
ai·rust·架构设计·系统设计·ai agent
mobility3 天前
免费AI视频生成器:我如何用零成本做出带旁白字幕的多场景AI视频
ai·vibe coding
doiito4 天前
【Agent Harness】Gliding Horse 给 Agent OS 装上双曲空间引擎与默克尔树边云同步
ai·rust·架构设计·系统设计·ai agent
knqiufan4 天前
从 Python 到 TypeScript,用 GLM-5.2 跑通 PowerMem SDK 的长程任务工程
ai·memory·agentic·powermem