Learning Path
浏览 PyTorch 相关教程与章节。
AI Agent、机器学习、深度学习、数据分析与 Python 科学计算。
教程
525
PyTorch torch.fake_quantize_per_tensor_affine 函数 Pytorch torch 参考手册 torch.fake_quantize_per_tensor_affine 是 PyTorch 中用于对张量进行张量级假量化(Fake Quantization)的函数。 函数定义 torch.fake_quantize_per_tensor_affine(input, scale, zero..
PyTorch torch.fix 函数 PyTorch torch.fix 函数 Pytorch torch 参考手册 torch.fix 是 PyTorch 中用于逐元素取整数部分(向零取整)的函数。 函数定义 torch.fix(input, *, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 取整数部分示例 x = ..
PyTorch torch.flatten 函数 Pytorch torch 参考手册 torch.flatten 是 PyTorch 中用于将张量展平的函数。 函数定义 torch.flatten(input, start_dim, end_dim, out) 使用示例 实例 [mycode4 type='python'] import torch x = torch.randn(2, 3, ..
PyTorch torch.flip 函数 Pytorch torch 参考手册 torch.flip 是 PyTorch 中用于沿指定维度翻转张量的函数。 函数定义 torch.flip(input, dims) 使用示例 实例 [mycode4 type='python'] import torch x = torch.arange(8).reshape(2, 4) print('..
PyTorch torch.fliplr 函数 Pytorch torch 参考手册 torch.fliplr 是 PyTorch 中用于左右翻转(水平翻转)张量的函数。 函数定义 torch.fliplr(input) 使用示例 实例 [mycode4 type='python'] import torch # 二维张量左右翻转 x = torch.arange(12).reshape(3, ..
PyTorch torch.flipud 函数 Pytorch torch 参考手册 torch.flipud 是 PyTorch 中用于上下翻转(垂直翻转)张量的函数。 函数定义 torch.flipud(input) 使用示例 实例 [mycode4 type='python'] import torch # 二维张量上下翻转 x = torch.arange(12).reshape(3, ..
PyTorch torch.float_power 函数 PyTorch torch.float_power 函数 Pytorch torch 参考手册 torch.float_power 是 PyTorch 中用于逐元素浮点幂运算的函数。 函数定义 torch.float_power(input, exponent, *, out=None) 使用示例 实例 [mycode4 type='python..
PyTorch torch.floor 函数 Pytorch torch 参考手册 torch.floor 是 PyTorch 中用于逐元素向下取整的函数。 函数定义 torch.floor(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch x = torch.tensor([1.1, 2.5, 3.7, -1.2]) ..
PyTorch torch.floor_divide 函数 PyTorch torch.floor_divide 函数 Pytorch torch 参考手册 torch.floor_divide 是 PyTorch 中用于逐元素整除的函数。 函数定义 torch.floor_divide(input, other, *, out=None) 使用示例 实例 [mycode4 type='python&#..
PyTorch torch.fmax 函数 Pytorch torch 参考手册 torch.fmax 是 PyTorch 中用于逐元素取最大值的函数(忽略NaN)。当输入中包含NaN时,torch.maximum会返回NaN,而torch.fmax会忽略NaN并返回非NaN值。 函数定义 torch.fmax(input, other) 使用示例 实例 [mycode4 type='python'..
PyTorch torch.fmin 函数 Pytorch torch 参考手册 torch.fmin 是 PyTorch 中用于逐元素取最小值的函数(忽略NaN)。当输入中包含NaN时,torch.minimum会返回NaN,而torch.fmin会忽略NaN并返回非NaN值。 函数定义 torch.fmin(input, other) 使用示例 实例 [mycode4 type='python'..
PyTorch torch.fmod 函数 Pytorch torch 参考手册 torch.fmod 是 PyTorch 中用于计算逐元素取模余数的函数。 函数定义 torch.fmod(input, other, out) 使用示例 实例 [mycode4 type='python'] import torch # 计算逐元素取模 x = torch.tensor([10, 15, 20])..
PyTorch torch.frac 函数 Pytorch torch 参考手册 torch.frac 是 PyTorch 中用于计算逐元素小数部分的函数。 函数定义 torch.frac(input, out) 使用示例 实例 [mycode4 type='python'] import torch # 计算小数部分 x = torch.tensor([1.5, 2.7, 3.1, 4.9])..
PyTorch torch.frexp 函数 Pytorch torch 参考手册 torch.frexp 是 PyTorch 中用于将浮点数分解为尾数(mantissa)和指数(exponent)的函数。 函数定义 torch.frexp(input) 返回两个张量: mantissa - 尾数部分,范围在 [-0.5, 1) exponent - 指数部分,为整数 使用示例 实例 [mycode4 typ..
PyTorch torch.from_dlpack 函数 Pytorch torch 参考手册 torch.from_dlpack 是 PyTorch 中用于从 dlpack 张量创建 PyTorch 张量的函数。 函数定义 torch.from_dlpack(ext_tensor) 使用示例 实例 [mycode4 type='python'] import torch # 创建张量 x = ..
PyTorch torch.from_numpy 函数 Pytorch torch 参考手册 torch.from_numpy 是 PyTorch 中用于从 NumPy 数组创建张量的函数。创建的张量与原始 NumPy 数组共享内存。 这在需要同时使用 PyTorch 和 NumPy 进行数据处理的场景中非常有用。 函数定义 torch.from_numpy(ndarray) 参数: ndarray (numpy.nd..
PyTorch torch.frombuffer 函数 Pytorch torch 参考手册 torch.frombuffer 是 PyTorch 中用于从 buffer 创建一维张量的函数。 函数定义 torch.frombuffer(buffer, dtype, count, offset) 使用示例 实例 [mycode4 type='python'] import torch import..
PyTorch torch.full 函数 Pytorch torch 参考手册 torch.full 是 PyTorch 中用于创建填充指定值的张量的函数。 函数定义 torch.full(size, fill_value, dtype=None, device=None, requires_grad=False) 使用示例 实例 [mycode4 type='python'] import t..
PyTorch torch.full_like 函数 Pytorch torch 参考手册 torch.full_like 是 PyTorch 中用于创建与输入张量相同形状的填充张量的函数。 函数定义 torch.full_like(input, fill_value, dtype=None, device=None, requires_grad=False) 使用示例 实例 [mycode4 type='..
PyTorch torch.gather 函数 Pytorch torch 参考手册 torch.gather 是 PyTorch 中用于沿指定维度收集指定索引元素的函数。 函数定义 torch.gather(input, dim, index, sparse_grad) 使用示例 实例 [mycode4 type='python'] import torch x = torch.tensor(..
PyTorch torch.ge 函数 Pytorch torch 参考手册 torch.ge 是 PyTorch 中用于逐元素大于等于比较的函数。 函数定义 torch.ge(input, other, out) 使用示例 实例 [mycode4 type='python'] import torch # 逐元素大于等于比较 x = torch.tensor([1, 2, 3, 4]) y =..
PyTorch torch.geqrf 函数 Pytorch torch 参考手册 torch.geqrf 是 PyTorch 中用于计算矩阵 QR 分解的函数,返回 Q 和 R 矩阵。 函数定义 torch.geqrf(input) 返回: a - 正交矩阵 Q tau - 产生正交矩阵所需的因子 使用示例 实例 [mycode4 type='python'] import torch ..
PyTorch torch.ger 函数 Pytorch torch 参考手册 torch.ger 是 PyTorch 中用于计算两个向量的外积(Gram 矩阵)的函数。 函数定义 torch.ger(input, vec2, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 创建两个向量 vec1 = torch.tensor([..
PyTorch torch.get_default_device 函数 Pytorch torch 参考手册 torch.get_default_device 是 PyTorch 中用于获取当前默认设备的函数。 函数定义 torch.get_default_device() 使用示例 实例 [mycode4 type='python'] import torch device = torch.g..