我有一个 4D 张量,我想获得最后两个维度的 argmax。torch.argmax只接受整数作为“dim”参数,而不接受元组。
我怎样才能做到这一点?
这就是我的想法,但我不知道如何匹配我的两个“索引”张量的维度。original_array是形状 [1, 512, 37, 59]。
max_vals, indices_r = torch.max(original_array, dim=2)
max_vals, indices_c = torch.max(max_vals, dim=2)
indices = torch.hstack((indices_r, indices_c))
Run Code Online (Sandbox Code Playgroud) 我试图c_library()在Bazel中实现自定义规则,该规则将一堆.c文件作为输入并生成.a静态库。在我的实现中,.c文件生成.o对象,然后将其归档到.a库中。但是似乎.o没有生成文件。这是自定义c_library()规则(rules.bzl文件):
def _change_ext_to_x( file_list, x = 'o' ):
# inputs a file list (i.e. string list)
# and changes their extensions to '.{x}'
return [ "".join( onefile.split('.')[:-1] ) + '.' + x \
for onefile in file_list ]
def _str_to_File( ctx, file_list ):
# A constructor of File() object
# pass the context
return [ ctx.new_file( onefile ) for onefile in file_list …Run Code Online (Sandbox Code Playgroud)