摘要: ...代指多个:,:。 import numpy as np w1=[] for j in range(5): if j!=0: w1.append((j*1,j*1+1,0)) w1=np.array(w1) #print(w1) #print(w1[:,:-1]) e=w1[:,:-1] br= 阅读全文
posted @ 2022-12-24 17:38 祥瑞哈哈哈 阅读(448) 评论(0) 推荐(0)
摘要: np.pad就是把x的上下左右都补上维。 import numpy as np x=np.arange(12).reshape((3,4)) x=np.pad(x, [(2, 2), (2, 2)], mode='constant') print(x) [[ 0 0 0 0 0 0 0 0] [ 0 阅读全文
posted @ 2022-12-24 13:24 祥瑞哈哈哈 阅读(257) 评论(0) 推荐(0)
摘要: 把维度进行压缩A*1*B就会变成A*B也可以使用torch.squeeze去压缩指定维度,如果压缩的指定维度不为1则返回原数组。 import torch import numpy as np x=np.arange(24).reshape((2,1,3,4)) x = torch.tensor(x 阅读全文
posted @ 2022-12-24 11:48 祥瑞哈哈哈 阅读(41) 评论(0) 推荐(0)
摘要: 就是在指定维度前再插入一个新的维度。 import torch import numpy as np x=np.arange(24).reshape((2,3,4)) x = torch.tensor(x) print(x) y=x.permute((2, 0, 1)) print(y.shape) 阅读全文
posted @ 2022-12-24 08:05 祥瑞哈哈哈 阅读(55) 评论(0) 推荐(0)
摘要: permute进行的是置换。 permute的dim需要参数表示进行置换的维度。 import torch import numpy as np x=np.arange(24).reshape((2,3,4)) x = torch.tensor(x) print(x) y=x.permute((2, 阅读全文
posted @ 2022-12-24 07:44 祥瑞哈哈哈 阅读(193) 评论(0) 推荐(0)