假设我们有一个 3 行 2 列的矩阵 as mat,我想在每 3 行上应用what_functions_to_apply_list我定义的 list 函数之一。所以输出 np.apply_along_axis应该是函数输出维度的 3 行。
如果不以矢量化方式进行循环,我该如何做到这一点?
例如
def f1(inp1,inp2):
return out1, out2
在哪里
functions_dic = {'f1': func1, 'f2':func2, 'f3':func3}
what_functions_to_apply_list = ['f1','f1','f2']
funcs_inputs = [[inp11,inp12], [inp21,inp32], [inp31,inp32]]
mat = np.ones((3, 2))
np.apply_along_axis(what_functions_to_apply_list , 1, mat)
互换的青春
相关分类