File size: 687 Bytes
7f50cd1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import numpy as np
import torch
from torch import Tensor
'''
numpy evaluation may have some problems, please check.
Here, an interesting thing is that, PBI and COSMOS are not MOO agg functions.
I.e., the optimas may not be Pareto optimal.
'''
def tche(f_arr, w, z=0):
if type(f_arr) == Tensor:
idx = torch.argmax(w * (f_arr - z), axis=1)
return f_arr[torch.arange(f_arr.shape[0]), idx]
# return [0]
elif type(f_arr) == np.ndarray:
idx = np.argmax(w * (f_arr - z), axis=1)
return f_arr[np.arange(f_arr.shape[0]), idx]
# return np.max(w * (f_arr - z), axis=1)
else:
raise Exception('type not supported')
|