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]])
'''
相关推荐
带刺的坐椅7 小时前
从 Claude Code 隐私争议,看 SolonCode 的设计选择
ai·llm·agent·claudecode·soloncode·codingplan
lincats11 小时前
Claude Code项目越写越乱?这套清理流程能救你
ai·ai agent·claude code
云燕实验室CloudLab15 小时前
《AI开始"抱团"思考了!多智能体 + 思维图到底有多强?》
ai·学习工具·智慧学伴
小七-七牛开发者15 小时前
论文解读:DeepSeek DSpark 在真实高并发推理服务中,如何保证 Token 生成又好又快?
ai·大模型·编程·ai coding
doiito1 天前
【Agent Harness】Gliding Horse 核心设计理念,不跟风开发自己的AI Agent
ai·rust·架构设计·系统设计·ai agent
hboot1 天前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
doiito2 天前
【Agent Harness】Gliding Horse 的 L2 作战地图:让多 Agent 协作从“摸黑”变成“透明”
ai·rust·架构设计·系统设计·ai agent
xiezhr2 天前
逛GitHub发现一款免费带有AI功能的数据库管理工具DBX
ai·开源软件·自然语言·数据库管理工具
垚森4 天前
我用 GLM-5.2 造了个炸裂主题后台:16 套主题随心切,可在线体验
ai·react
doiito4 天前
【Agent Harness】Gliding Horse 工具结果压缩体系:如何用“指针”驯服上下文膨胀
ai·rust·架构设计·系统设计·ai agent