numpy
-
scatter_(input, dim, index, src)将src中数据根据index中的索引按照dim的方向填进input中.
-
numpy.clip(a, a_min, a_max, out=None) 将array a的值限制在a_min, a_max两个数之间
-
np.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation=‘linear’, keepdims=False) 百分位数是统计中使用的度量,表示小于这个值的观察值的百分比。
-
numpy.repeat()重复
np.repeat(3, 4) #array([3, 3, 3, 3]) x = np.array([[1,2],[3,4]]) np.repeat(x, 2) #array([1, 1, 2, 2, 3, 3, 4, 4]) np.repeat(x, 3, axis=1) #array([[1, 1, 1, 2, 2, 2], # [3, 3, 3, 4, 4, 4]]) np.repeat(x, [1, 2], axis=0) #array([[1, 2], # [3, 4], # [3, 4]])
-
np.linspace() 用于在线性空间中以均匀步长生成数字序列。 第一个参数是开头,第二个参数是结尾,第三个参数是多少步。
skimage
- skimage.restoration.denoise_bilateral(image, win_size=None, sigma_color=None, sigma_spatial=1, bins=10000, mode=‘constant’, cval=0, multichannel=None, sigma_range=None) 使用双边滤波器去噪图像。
pytorch
-
torch.load()加载模型
-
model.eval ()使得所有层进入评估模式,非训练模式
-
model.cuda()模型加载到gpu
-
transform.compose()把两个操作合并在一起
-
transform.ToTensor()#把H,W,C转为C,H,W
-
torch.unqueeze()返回一个新的张量,在指定位置插入一个大小为1的维度。返回的张量与该张量共享相同的基础数据。
x = torch.tensor([1, 2, 3, 4]) torch.unsqueeze(x, 0) #tensor([[ 1, 2, 3, 4]]) torch.unsqueeze(x, 1) #tensor([[ 1], # [ 2], # [ 3], # [ 4]])
-
torch.cat(inputs, dimension=0) → Tensor 在给定维度上对输入的张量序列seq 进行连接操作。
>>> x = torch.randn(2, 3) >>> x 0.5983 -0.0341 2.4918 1.5981 -0.5265 -0.8735 [torch.FloatTensor of size 2x3] >>> torch.cat((x, x, x), 0) 0.5983 -0.0341 2.4918 1.5981 -0.5265 -0.8735 0.5983 -0.0341 2.4918 1.5981 -0.5265 -0.8735 0.5983 -0.0341 2.4918 1.5981 -0.5265 -0.8735 [torch.FloatTensor of size 6x3] >>> torch.cat((x, x, x), 1) 0.5983 -0.0341 2.4918 0.5983 -0.0341 2.4918 0.5983 -0.0341 2.4918 1.5981 -0.5265 -0.8735 1.5981 -0.5265 -0.8735 1.5981 -0.5265 -0.8735 [torch.FloatTensor of size 2x9]
-
outputs = torch.stack(inputs, dim=0) → Tensor
增加新的维度进行堆叠 -
torch.permute()转置
-
torch.view()相当于numpy的resize()
-
torch.repeat(n1,n2,n3,n4),第1维、第2维、第3维、第4维的重复次数
-
torch.detach() 克隆,但将计算图脱离出来,就是两个分开。
MoviePy
- ImageSequenceClip图片创建视频