torch.nn.functional.interpolate函数

torch.nn.functional.interpolate(input, size=None, scale_factor=None, mode='nearest', align_corners=None, recompute_scale_factor=None, antialias=False)

Down/up samples the input to either the given size or the given scale_factor

The algorithm used for interpolation is determined by mode.

Currently temporal, spatial and volumetric sampling are supported, i.e. expected inputs are 3-D, 4-D or 5-D in shape.

The input dimensions are interpreted in the form: mini-batch x channels x [optional depth] x [optional height] x width.

The modes available for resizing are: nearest, linear (3D-only), bilinear, bicubic (4D-only), trilinear (5D-only), area, nearest-exact

官方文档给的解释是进行上下采样到指定大小,可以理解是对图片进行缩放,可以将图片缩放到指定大小。mode为调整的大小模式,有些只支持4D,5D,要先对数据进行处理,增加维度后才可以使用。例如对于一个三维的图像,要使用双三次插值,因为双三次插值只支持思维数据,可以使用torch.unsqueeze()对数据增加1的维度

torch.unsqueeze(x,0)

即在数据的第0个维度添加1,例如一个3*64*64的数据,经过处理后变为1*3*64*64

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值