【笔记】pytorch语法 torch.repeat & torch.expand

您所在的位置:网站首页 torchrepeat函数 【笔记】pytorch语法 torch.repeat & torch.expand

【笔记】pytorch语法 torch.repeat & torch.expand

2023-09-30 06:24| 来源: 网络整理| 查看: 265

torch.repeat 与 torch.expand 比较

torch.repeat和torch.expand的区别: 对比

与numpy类似函数的比较 torch.repeat

torch.repeat用法类似np.tile,同时numpy中也有一个repeat,用法对应torch中的 torch.repeat_interleave。 这两者的类似都是在参数层面和使用方法上的类似,torch.repeat和torch.repeat_interleave得到的结果与输入都没有关联。

torch.expand

torch.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