说我是否有张量
values = torch.tensor([5., 4., 8., 3.])
我想在每2个连续值中取最小值,这意味着
min(5., 4.) = 4.
min(8., 3.) = 3.
是否有矢量化的方式来做到这一点,但仍能获得最小值的相对指数?我要作为输出的意思是:
min_index = [1, 1]
#min_index[0] == 1 as 4. is the minimum of (5., 4.) and is in index 1 of (5., 4.)
#min_index[1] == 1 as 3. is the minimum of (8., 3.) and is in index 1 of (8., 3.)
答案 0 :(得分:2)
我认为重塑张量将使它变得容易得多。
之后,max-width: 100vw;
overflow-x: hidden;
自动返回最小值和索引。
torch.min
答案 1 :(得分:0)
这里有一个numpy实现:
Supplier<Stream<? extends Long>> longStreamSupplier = ..