Pytorch_1_基本语法

一、Pytorch的基本元素操作

1.引入torch

复制代码
from __future__ import print_function
import torch

2.创建矩阵

复制代码
x = torch.empty(5,3)
print(x)

3.输出结果:

tensor(\[7.9191e+34, 1.1259e+24, 1.2359e-42,

4.0824e-40, 1.1379e-35, 2.5353e+30,

8.4078e-45, 2.6709e-42, 7.7558e-40,

2.9130e-33, 2.5353e+30, 9.6690e-44,

7.5524e+28, 5.2839e-11, 1.3458e-14])

4.指定一个全零矩阵并可指定数据元素的类型为long

复制代码
x = torch.zeros(5,3, dtype=torch.long)
print(x)

5.输出结果

tensor(\[0, 0, 0,

0, 0, 0,

0, 0, 0,

0, 0, 0,

0, 0, 0])

未完待续。。。

相关推荐
Henry-SAP13 小时前
SAP引领ERP智能化转型
人工智能·云原生·sap·erp
峥嵘life14 小时前
Android16 311Y3 EAP-TLS 网络连接失败分析与修复总结
android·开发语言·人工智能·php
特立独行的猫a14 小时前
一切皆插件:DeepSeek Harness 的架构哲学,以及与主流 Agent 的对比
人工智能·架构·agent·deepseek·harness
电商API_1800790524714 小时前
京东商品详情API技术文章
大数据·运维·人工智能·网络爬虫
fīɡЙtīиɡ ℡15 小时前
AI Agent 记忆系统
人工智能
企鹅的企15 小时前
2027北京AI数字健康与智慧医疗展官方:超两成展品亚洲首秀
人工智能·科技·机器人
lvts_cs15 小时前
淄博高新区绿天使数智创新港:高标准产研厂房全维度详解
大数据·人工智能
百胜软件@百胜软件16 小时前
从“人找货”到“货找人”:「胜券商品」如何用AI重构配补调
人工智能·重构
jufeng130716 小时前
【系列:手搓自主 AI Agent:Hermes 架构原理剖析 · 第 11 篇】
python·ai agent·mcp