【笔记】pytorch语法 torch.repeat & torch.expand |
您所在的位置:网站首页 › torchrepeat函数 › 【笔记】pytorch语法 torch.repeat & torch.expand |
torch.repeat 与 torch.expand 比较
torch.repeat和torch.expand的区别: torch.repeat用法类似np.tile,同时numpy中也有一个repeat,用法对应torch中的 torch.repeat_interleave。 这两者的类似都是在参数层面和使用方法上的类似,torch.repeat和torch.repeat_interleave得到的结果与输入都没有关联。 torch.expandtorch.expand的结果与输入有关联,见上图中例子,类似numpy.broadcast_to。同时numpy.broadcast_to在使用方法上类似np.tile。 总结torch.repeat与torch.expand的差异,类似np.tile与np.broadcast_to的差异。 torchnumpy是否broadcast参数类型和使用方法torch.repeatnp.tile否Atorch.expandnp.broadcast_to是Atorch.repeat_interleavenp.repeat否B |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |