Learning Path
浏览 PyTorch 相关教程与章节。
AI Agent、机器学习、深度学习、数据分析与 Python 科学计算。
教程
525
PyTorch torch.nan_to_num 函数 Pytorch torch 参考手册 torch.nan_to_num 是 PyTorch 中用于将张量中的 NaN 值替换为指定值的函数。也可以替换无穷值。 函数定义 torch.nan_to_num(input, nan=0.0, posinf=None, neginf=None, out=None) 使用示例 实例 [mycode4 type='..
PyTorch torch.nanmean 函数 Pytorch torch 参考手册 torch.nanmean 是 PyTorch 中用于计算忽略 NaN 值的平均值的函数。 函数定义 torch.nanmean(input, dim, keepdim=False, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 创建包含 N..
PyTorch torch.nanmedian 函数 Pytorch torch 参考手册 torch.nanmedian 是 PyTorch 中用于返回张量的非NaN值的中位数的函数。与 median 不同的是,它会忽略所有的 NaN 值。 函数定义 torch.nanmedian(input, dim, keepdim=False) 使用示例 实例 [mycode4 type='python'..
PyTorch torch.nanquantile 函数 Pytorch torch 参考手册 torch.nanquantile 是 PyTorch 中用于返回张量的非NaN值的分位数的函数。与 quantile 不同的是,它会忽略所有的 NaN 值。 函数定义 torch.nanquantile(input, q, dim, keepdim=False) 使用示例 实例 [mycode4 type='p..
PyTorch torch.nansum 函数 Pytorch torch 参考手册 torch.nansum 是 PyTorch 中用于返回张量的非NaN值之和的函数。与 sum 不同的是,它会忽略所有的 NaN 值。 函数定义 torch.nansum(input, dim, keepdim=False) 使用示例 实例 [mycode4 type='python'] import torch..
PyTorch torch.narrow 函数 Pytorch torch 参考手册 torch.narrow 是 PyTorch 中用于返回张量切片的函数。它返回指定维度上从起始位置到指定长度的切片视图。 函数定义 torch.narrow(input, dim, start, length) 参数: input (Tensor): 输入张量。 dim (int): 要进行切片的维度。 start (int): 起始索..
PyTorch torch.narrow_copy 函数 Pytorch torch 参考手册 torch.narrow_copy 是 PyTorch 中用于返回张量切片副本的函数。它返回指定维度上从起始位置到指定长度的切片的副本。 该函数与 torch.narrow 的功能类似,但 torch.narrow 返回视图,而 torch.narrow_copy 返回副本。 函数定义 torch.narrow_copy(inpu..
PyTorch torch.ne 函数 Pytorch torch 参考手册 torch.ne 是 PyTorch 中用于逐元素不等比较的函数。 函数定义 torch.ne(input, other, out) 使用示例 实例 [mycode4 type='python'] import torch a = torch.tensor([1, 2, 3, 4]) b = torch.tensor(..
PyTorch torch.neg 函数 Pytorch torch 参考手册 torch.neg 是 PyTorch 中用于逐元素取负的函数。 函数定义 torch.neg(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 逐元素取负 x = torch.tensor([1.0, 2.0, 3.0]) result ..
PyTorch torch.negative 函数 Pytorch torch 参考手册 torch.negative 是 PyTorch 中用于逐元素取负的函数。与 torch.neg 功能相同。 函数定义 torch.negative(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 逐元素取负 x = torch..
PyTorch torch.nextafter 函数 Pytorch torch 参考手册 torch.nextafter 是 PyTorch 中用于逐元素返回下一个可表示的浮点数的函数。 函数定义 torch.nextafter(input, other, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 返回下一个可表示的浮点数..
PyTorch torch.nn.AdaptiveAvgPool2d 函数 PyTorch torch.nn 参考手册 torch.nn.AdaptiveAvgPool2d 是 PyTorch 中的自适应平均池化模块。 它可以将任意尺寸的输入特征图池化到指定的目标尺寸,无需手动计算 kernel_size 和 stride。 函数定义 torch.nn.AdaptiveAvgPool2d(output_size) 参数说明: ..
PyTorch torch.nn.AdaptiveMaxPool2d 函数 PyTorch torch.nn 参考手册 torch.nn.AdaptiveMaxPool2d 是 PyTorch 中的自适应最大池化模块。 它将输入池化到指定尺寸,保留最大值而非平均值。 函数定义 torch.nn.AdaptiveMaxPool2d(output_size, return_indices=False) 参数 output_si..
PyTorch torch.nn.AvgPool2d 函数 PyTorch torch.nn 参考手册 torch.nn.AvgPool2d 是 PyTorch 中的二维平均池化模块。 它对输入的每个窗口计算平均值,常用于下采样和特征汇聚。 函数定义 torch.nn.AvgPool2d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad..
PyTorch torch.nn.BatchNorm2d 函数 PyTorch torch.nn 参考手册 torch.nn.BatchNorm2d 是 PyTorch 中用于二维批归一化的模块。 批归一化通过规范化层的输入来加速训练、稳定收敛,是现代深度神经网络中最常用的技术之一。 函数定义 torch.nn.BatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=T..
PyTorch torch.nn.BCEWithLogitsLoss 函数 PyTorch torch.nn 参考手册 torch.nn.BCEWithLogitsLoss 是 PyTorch 中的二元交叉熵损失函数(带 Sigmoid)。 它将 Sigmoid 和 BCE 结合,数值更稳定,用于二分类任务。 函数定义 torch.nn.BCEWithLogitsLoss(weight=None, reduction='..
PyTorch torch.nn.Bilinear 函数 PyTorch torch.nn 参考手册 torch.nn.Bilinear 是 PyTorch 中的双线性层。 它对两个输入进行双线性变换,常用于特征融合。 函数定义 torch.nn.Bilinear(in1_features, out_features, out_features, bias=True) 公式 y = x1 * W * x2 + b 使..
PyTorch torch.nn.Conv1d 函数 PyTorch torch.nn 参考手册 torch.nn.Conv1d 是 PyTorch 中的一维卷积模块。 主要用于处理序列数据,如文本、音频和时间序列信号。 函数定义 torch.nn.Conv1d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, b..
PyTorch torch.nn.Conv2d 函数 PyTorch torch.nn 参考手册 torch.nn.Conv2d 是 PyTorch 中用于二维卷积的模块,是卷积神经网络(CNN)的核心组件。 它通过对输入张量应用可学习的卷积核来提取空间特征,广泛用于图像处理和计算机视觉任务。 函数定义 torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=..
PyTorch torch.nn.Conv3d 函数 PyTorch torch.nn 参考手册 torch.nn.Conv3d 是 PyTorch 中的三维卷积模块。 它处理三维输入,如视频或医学图像(深度 x 高 x 宽)。 函数定义 torch.nn.Conv3d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=..
PyTorch torch.nn.ConvTranspose2d 函数 PyTorch torch.nn 参考手册 torch.nn.ConvTranspose2d 是 PyTorch 中的二维转置卷积,也称为反卷积或上采样卷积。 它用于上采样特征图,是生成网络和分割网络的关键组件。 函数定义 torch.nn.ConvTranspose2d(in_channels, out_channels, kernel_size, str..
PyTorch torch.nn.CrossEntropyLoss 函数 PyTorch torch.nn 参考手册 torch.nn.CrossEntropyLoss 是 PyTorch 中用于多分类的损失函数。 它结合了 nn.LogSoftmax 和 nn.NLLLoss,常用于图像分类、文本分类等任务。 函数定义 torch.nn.CrossEntropyLoss(weight=None, ignore_index=-1..
PyTorch torch.nn.Dropout 函数 PyTorch torch.nn 参考手册 torch.nn.Dropout 是 PyTorch 中用于正则化的模块。 它通过随机将输入元素的置零来减少神经元之间的协同适应,从而防止过拟合。 函数定义 torch.nn.Dropout(p=0.5, inplace=False) 参数说明: p (float): 每个元素被置零的概率。默认为 0.5。 inplace (..
PyTorch torch.nn.Dropout2d 函数 PyTorch torch.nn 参考手册 torch.nn.Dropout2d 是 PyTorch 中的二维 Dropout 模块。 它随机将整个通道置零,适合卷积层的特征图。 函数定义 torch.nn.Dropout2d(p=0.5, inplace=False) 特点 按通道(channel)维度随机置零 每个样本的所有通道保持一致的丢弃模式 使用..