我是 Python/Pytorch 用户。首先,在 numpy 中,假设我有一个大小为 LxL 的数组 M,并且我想要以下数组:A=(M,...,M) 大小,例如 NxLxL,是否有更优雅的/内存这样做的有效方法比:
A=np.array([M]*N) ?
Run Code Online (Sandbox Code Playgroud)
与火炬张量相同的问题!原因,现在,如果 M 是一个变量(torch.tensor),我必须这样做:
A=torch.autograd.Variable(torch.tensor(np.array([M]*N)))
Run Code Online (Sandbox Code Playgroud)
这是丑陋的!