分类目录:《深入浅出Pytorch函数》总目录
相关文章:
· 深入浅出Pytorch函数——torch.Tensor
· 深入浅出Pytorch函数——torch.ones
· 深入浅出Pytorch函数——torch.zeros
· 深入浅出Pytorch函数——torch.full
· 深入浅出Pytorch函数——torch.ones_like
· 深入浅出Pytorch函数——torch.zeros_like
· 深入浅出Pytorch函数——torch.full_like
返回一个形状与
input
相同且值全为
fill_value
的张量。
full_like(input, fill_value)
相当于
torch.full(input.size(), fill_value, dtype=input.dtype, layout=input.layout, device=input.device)
。
语法
torch.full_like(input, fill_value, \*, dtype=None, layout=torch.strided, device=None, requires_grad=False, memory_format=torch.preserve_format) → Tensor
参数
input:[Tensor]input向量的形状决定了输出向量的形状。fill_value:填入输出tensor的值dtype:[可选,torch.dtype] 返回张量的所需数据类型。如果为None,则使用全局默认值(参考torch.set_default_tensor_type())。layout:[可选,torch.layout] 返回张量的期望内存布局形式,默认为torch.strided。device:返回张量的期望计算设备。如果为None,使用当前的设备(参考torch.set_default_tensor_type()),设备将CPU用于CPU张量类型,将CUDA设备用于CUDA张量类型。requires_grad:[可选,bool] 是否需要自动微分,默认为False。memory_format:[可选,torch.memory_format] 返回张量的所需内存格式,默认为torch.preserve_format。
返回值
返回一个形状与
input
相同且值全为
fill_value
的张量。
版权归原作者 von Neumann 所有, 如有侵权,请联系我们删除。