iT邦幫忙

0

關於pytorch Tensor相關問題

  • 分享至 

  • xImage

https://ithelp.ithome.com.tw/upload/images/20200625/20110042ST0eoD1ZI9.jpg
我想請問一下如果我想要知道tensor(56, device='cuda:0')這個在以下這個Tensor所在的位置有什麼辦法可以做到呢?pytorch是否有相關套件可以達到此效果,謝謝
tensor([ 56, 83, 41, 29, 43, 112, 3, 86, 65, 96, 124, 84, 40, 25,
76, 4, 132, 12, 99, 78, 42, 63, 37, 144, 130, 13, 52, 57,
137, 116, 93, 67, 54, 46, 55, 38, 5, 16, 17, 19, 88, 69,
68, 39, 18, 85, 81, 32, 61, 147, 95, 74, 127, 14, 104, 64,
50, 94, 10, 59, 6, 7, 140, 131, 129, 87, 105, 28, 58, 119,
60, 73, 97, 107, 79, 120, 123, 118, 8, 9, 106, 62, 2, 102,
82, 75, 145, 70, 30, 121, 51, 66, 101, 136, 71, 44, 72, 110,
122, 92, 126, 77, 108, 0, 111, 24, 53, 114, 91, 31, 128, 139,
109, 49, 33, 113, 134, 135, 34, 45, 142, 143, 36, 89, 23, 115,
141, 138, 103, 125, 100, 20, 11, 21, 98, 35, 48, 146, 133, 22,
26, 90, 117, 148, 80, 47, 27, 15, 1], device='cuda:0')

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
增廣建文
iT邦研究生 5 級 ‧ 2021-10-15 13:20:03

有兩個方法:

  1. 直接把他放回cpu轉numpy來找
  2. 善用==與nonzero, https://stackoverflow.com/a/47867513

我要發表回答

立即登入回答