torch 常用 函数 (10 - 2 )
发布时间
阅读量:
阅读量
索引、切片、连接、换位
PyTorch张量拼接函数
torch.cat(inputs, dimension=0) → Tensor
在指定维度上对输入的张量序列seq执行拼接操作。torch.cat()可被视为torch.split()与torch.chunk()的逆向操作。cat()函数的功能可通过以下示例进行更清晰的阐释。参数包括:* inputs (sequence of Tensors) 该参数为任意一致类型Tensor的Python序列;* dimension (int, optional) 指定沿该维度对张量序列进行拼接。
PyTorch张量分割方法
torch.chunk(tensor, chunks, dim=0)
将输入张量按照指定维度进行分割处理。
参数说明如下:
- tensor (Tensor) – 需要进行分割操作的输入张量
- chunks (int) – 指定分割后的块数量
- dim (int) – 确定沿哪个维度执行分割操作
PyTorch张量操作详解
torch.gather(input, dim, index, out=None) → Tensor
按照所指定的维度dim,对输入的索引张量index中对应位置的数值进行
全部评论 (0)
还没有任何评论哟~
