使用Pytorch。 得到了以下张量:
(tensor([[-0.0030, -7.6063, -7.6334, -7.7098, -8.3540]], device='cuda:0'),
tensor([[ 14, 85, 45, 82, 15]], device='cuda:0'))
需要将其与以下字典结合起来:
{'14': 'a',
'100': 'b',
'45': 'c',
'33': 'd',
'15': 'e'}
为了获得以下结果: 'a','c','e'
答案 0 :(得分:1)
dictionary = {int(key):dictionary [key] for dictionary in key} np.vectorize(cat_to_name.get)(best_5)