对于tensor A和整数n之间的除法:
这个floor_divide相当于python中的'//',即得到的结果为整型(去掉了小数点后的数字)。
如果你不想要这种除法,想得到带小数点的准确数值,您可以:
根据具体情况选取以上两种除法,即可解决这个issue。
ps:
pytorch升级到1.6.0,发现tensor和int之间的除法不能直接用'/'。明明1.5.0都是可以用的-_-。这种邻代兼容性有点值得吐槽。
对于这个问题直接看官方文档就可以了:
https://pytorch.org/docs/stable/generated/torch.div.html
或者,看我的解决方案: