PyTorch布林型別的張量的+操作
阿新 • • 發佈:2020-12-27
技術標籤:零基礎學習SSD網路PyTorch實現Deep-Learning-with-PyTorch《深度學習之PyTorch實戰計算機視覺》
總結:
兩個元素為布林型別的張量進行+操作,其效果類似於逐元素求邏輯或運算.
C:\Users\chenxuqi>
C:\Users\chenxuqi>conda activate ssd4pytorch1_2_0
(ssd4pytorch1_2_0) C:\Users\chenxuqi>python
Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit ( AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>
>>> pos_idx = torch.tensor([[True,True],[False,False]])
>>> pos_idx
tensor([[ True, True],
[ False, False]])
>>>
>>> neg_idx = torch.tensor([[True,False],[True,False]])
>>> neg_idx
tensor([[ True, False],
[ True, False]])
>>>
>>> pos_idx + neg_idx
tensor([[ True, True],
[ True, False]])
>>>
>>>
>>>