Learning Path
浏览 PyTorch 相关教程与章节。
AI Agent、机器学习、深度学习、数据分析与 Python 科学计算。
教程
525
PyTorch torch.cuda.manual_seed_all 函数 Pytorch torch 参考手册 torch.cuda.manual_seed_all 是 PyTorch 中用于设置所有 CUDA 设备随机种子的函数。为所有 CUDA 设备设置随机种子。 函数定义 torch.cuda.manual_seed_all(seed) 使用示例 实例 [mycode4 type='python'..
PyTorch torch.cuda.memory_allocated 函数 Pytorch torch 参考手册 torch.cuda.memory_allocated 是 PyTorch 中用于获取已分配显存的函数。返回当前 CUDA 设备已分配的内存大小(以字节为单位)。 函数定义 torch.cuda.memory_allocated(device=None) 使用示例 实例 [mycode4 type='..
PyTorch torch.cuda.memory_reserved 函数 Pytorch torch 参考手册 torch.cuda.memory_reserved 是 PyTorch 中用于获取已保留显存的函数。返回 CUDA 缓存管理器当前保留的内存大小(以字节为单位)。 函数定义 torch.cuda.memory_reserved(device=None) 使用示例 实例 [mycode4 type='p..
PyTorch torch.cuda.seed 函数 Pytorch torch 参考手册 torch.cuda.seed 是 PyTorch 中用于设置 CUDA 随机种子的函数。为当前 CUDA 设备设置随机种子(功能与 manual_seed 相同)。 函数定义 torch.cuda.seed() 使用示例 实例 [mycode4 type='python'] import torch # 设置 ..
PyTorch torch.cuda.seed_all 函数 Pytorch torch 参考手册 torch.cuda.seed_all 是 PyTorch 中用于设置所有 CUDA 设备随机种子的函数。为所有 CUDA 设备设置随机种子(功能与 manual_seed_all 相同)。 函数定义 torch.cuda.seed_all() 使用示例 实例 [mycode4 type='python']..
PyTorch torch.cuda.synchronize 函数 Pytorch torch 参考手册 torch.cuda.synchronize 是 PyTorch 中用于 CUDA 同步的函数。等待所有 CUDA 核心完成当前任务,确保 CPU 和 GPU 操作同步。 函数定义 torch.cuda.synchronize(device=None) 使用示例 实例 [mycode4 type='python..
PyTorch torch.cuda 函数 Pytorch torch 参考手册 torch.cuda 是 PyTorch 中用于 CUDA 管理的模块。提供了 CUDA 设备管理、内存管理、同步等功能。 函数定义 torch.cuda torch.cuda 模块包含以下常用函数: torch.cuda.is_available() - 检查 CUDA 是否可用 torch.cuda.device_count() - 获取 C..
PyTorch torch.cummax 函数 Pytorch torch 参考手册 torch.cummax 是 PyTorch 中用于计算累积最大值的函数。它返回沿指定维度的累积最大值以及对应的索引。 函数定义 torch.cummax(input, dim, dtype=None) 使用示例 实例 [mycode4 type='python'] import torch # 计算累积最大值 x =..
PyTorch torch.cummin 函数 Pytorch torch 参考手册 torch.cummin 是 PyTorch 中用于计算累积最小值的函数。它返回沿指定维度的累积最小值以及对应的索引。 函数定义 torch.cummin(input, dim, dtype=None) 使用示例 实例 [mycode4 type='python'] import torch # 计算累积最小值 x =..
PyTorch torch.cumprod 函数 Pytorch torch 参考手册 torch.cumprod 是 PyTorch 中用于计算累积积的函数。它返回沿指定维度的累积乘积,即从开始到当前位置所有元素的乘积。 函数定义 torch.cumprod(input, dim, dtype=None) 使用示例 实例 [mycode4 type='python'] import torch # 计..
PyTorch torch.cumsum 函数 Pytorch torch 参考手册 torch.cumsum 是 PyTorch 中用于计算累积和的函数。它返回沿指定维度的累积和,即从开始到当前位置所有元素的和。 函数定义 torch.cumsum(input, dim, dtype=None) 使用示例 实例 [mycode4 type='python'] import torch # 计算累积和 ..
PyTorch torch.cumulative_trapezoid 函数 Pytorch torch 参考手册 torch.cumulative_trapezoid 是 PyTorch 中用于计算函数累积梯形积分的函数。它使用梯形法则计算函数在给定点的累积积分。 函数定义 torch.cumulative_trapezoid(y, x=None, dx=1.0, dim=-1) 参数: y (Tensor): 被积分的..
PyTorch torch.deg2rad 函数 PyTorch torch.deg2rad 函数 Pytorch torch 参考手册 torch.deg2rad 是 PyTorch 中用于将角度转换为弧度的函数。 函数定义 torch.deg2rad(input, *, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 角度..
PyTorch torch.dequantize 函数 Pytorch torch 参考手册 torch.dequantize 是 PyTorch 中用于将量化张量反量化为浮点张量的函数。 函数定义 torch.dequantize(input) 使用示例 实例 [mycode4 type='python'] import torch # 创建输入张量 input = torch.tensor(..
PyTorch torch.det 函数 Pytorch torch 参考手册 torch.det 是 PyTorch 中用于计算方阵行列式的函数。 函数定义 torch.det(input) 使用示例 实例 [mycode4 type='python'] import torch # 创建 2x2 矩阵 a = torch.tensor([[1.0, 2.0], [3.0, 4.0]]) #..
PyTorch torch.device 函数 Pytorch torch 参考手册 torch.device 是 PyTorch 中用于创建设备对象的函数,用于指定张量存储的设备。 函数定义 torch.device(device) 使用示例 实例 [mycode4 type='python'] import torch # 创建 CPU 设备 cpu_device = torch.devic..
PyTorch torch.diag 函数 Pytorch torch 参考手册 torch.diag 是 PyTorch 中用于创建对角矩阵或提取张量对角元素的函数。 函数定义 torch.diag(input, diagonal=0, out=None) 参数说明: input: 输入张量 diagonal: 对角线索引,0 表示主对角线,正值表示上方对角线,负值表示下方对角线 使用示例 实例 [mycod..
PyTorch torch.diag_embed 函数 Pytorch torch 参考手册 torch.diag_embed 是 PyTorch 中用于将输入张量作为对角线元素嵌入到新张量中的函数。它在输入的最后一个维度上创建对角线。 函数定义 torch.diag_embed(input, diagonal=0, offset=0) 参数说明: input: 输入张量 diagonal/offset: 对角线索引 ..
PyTorch torch.diagflat 函数 Pytorch torch 参考手册 torch.diagflat 是 PyTorch 中用于创建对角扁平矩阵的函数。无论输入是一维还是多维,都会被展平后作为对角线元素。 函数定义 torch.diagflat(input, diagonal=0) 参数说明: input: 输入张量,会被展平 diagonal: 对角线索引 使用示例 实例 [mycode4 ..
PyTorch torch.diagonal 函数 Pytorch torch 参考手册 torch.diagonal 是 PyTorch 中用于提取张量对角线元素的函数。它返回输入张量指定对角线的视图。 函数定义 torch.diagonal(input, diagonal=0, dim1=0, dim2=1) 参数说明: input: 输入张量 diagonal: 对角线索引,0 表示主对角线 dim1: 第一个维度..
PyTorch torch.diagonal_scatter 函数 Pytorch torch 参考手册 torch.diagonal_scatter 是 PyTorch 中用于将值散布到张量对角线位置的函数。它将 src 的值散布到 input 的指定对角线上。 函数定义 torch.diagonal_scatter(input, src, offset=0, dim1=0, dim2=1) 参数: input (Te..
PyTorch torch.diff 函数 Pytorch torch 参考手册 torch.diff 是 PyTorch 中用于计算张量相邻元素之间差值的函数。计算公式为 out[i] = input[i+1] - input[i]。 函数定义 torch.diff(input, n=1, dim=-1, prepend=None, append=None) 参数说明: input: 输入张量 n: 差分次数,默认为1..
PyTorch torch.digamma 函数 PyTorch torch.digamma 函数 Pytorch torch 参考手册 torch.digamma 是 PyTorch 中用于逐元素计算 psi 函数(对数导数)的函数。 函数定义 torch.digamma(input, *, out=None) 使用示例 实例 [mycode4 type='python'] import t..
PyTorch torch.dist 函数 Pytorch torch 参考手册 torch.dist 是 PyTorch 中用于计算两个张量之间距离的函数。 函数定义 torch.dist(input, other, p=2) 参数说明: input - 输入张量 other - 目标张量 p - 范数类型,默认为 2(欧几里得距离) 使用示例 实例 [mycode4 type='python&#..