图神经网络方向--论文代码读记
发布时间
阅读量:
阅读量
前言
此内容旨在记录本人在阅读论文并编写代码过程中的部分简易代码片段,便于日后查阅与参考。
一、torch.cat() 、torch.stack()
拼接张量:torch.cat() 、torch.stack()
- torch.cat(inputs, dimension=0) → Tensor
在指定的维度位置上,将输入的张量序列进行拼接处理
以下为具体示例:
>>> ``import` `torch``
>>> x ``=` `torch.randn(``2``, ``3``)``
>>> x``tensor([[``-``0.1997``, ``-``0.6900``, ``0.7039``],`` ``[ ``0.0268``, ``-``1.0140``, ``-``2.9764``]])``
>>> torch.cat((x, x, x), ``0``) ``
# 在 0 维(纵向)进行拼接``tensor([[``-``0.1997``, ``-``0.6900``, ``0.7039``],`` ``[ ``0.0268``, ``-``1.0140``, ``-``2.9764``],`` ``[``-``0.1997``, ``-``0.69
全部评论 (0)
还没有任何评论哟~
