torch.div()的使用举例
也就是 ab 挨个元素进行相除操作。
img.shape[-2:]/len(img.shape[-2:]):GeneralizedRCNN:original_image_sizes中的 torch._assert
也就是 后两个维度。0 代表行数。1代表列数。-2代表后两个维度
chw。也就是h和w的值。(h,w)
torch.where()的用法以及例子
cc = torch.where(a>0,a,b) #合并a,b两个tensor,如果a中元素大于0,则c中与a对应的位置取a的值,否则取b的值
torch.mul()函数。对两个张量进行逐元素乘法
python中format的用法详解:
https://blog.csdn.net/qq_42855293/article/details/118480087
format是字符串内嵌的一个方法,用于格式化字符串。以大括号{}来标明被替换的字符串。
s = 'π is {:.2f}'.format(3.1415926)
print(s) # π is 3.14
s1 = 'π is %.2f'% 3.1415926
print(s1) # π is 3.14