pytorch 扩展张量

目录

repeat函数

expand函数:

expand

expand_as函数:


repeat函数

import torch
a = torch.tensor([[1, 2, 3],[1, 2, 3]])
print(a)


b = torch.tensor([[2, 2, 2], [3, 3, 3], [3, 3, 3], [3, 3, 3]])
print(a.shape,b.size())
c = a.repeat(2,1)
print(c)
print(c.size())

expand

你可能感兴趣的:(pytorch知识宝典,pytorch,深度学习,python)