MuseVSpace / MuseV /MMCM /mmcm /utils /compute_util.py
anchorxia's picture
add mmcm
a57c6eb
raw
history blame contribute delete
469 Bytes
from typing import List
import numpy as np
def weighted_sum(weights: List[float], datas: List[np.array]) -> np.array:
"""ε―ΉηŸ©ι˜΅εˆ—θ‘¨ζŒ‰η…§ζƒι‡εˆ—θ‘¨εŠ ζƒζ±‚ε’Œ
Args:
weights (list): ζƒι‡εˆ—θ‘¨
datas (list): ηŸ©ι˜΅εˆ—θ‘¨
Returns:
np.array: εŠ ζƒζ±‚ε’ŒεŽηš„ηŸ©ι˜΅
"""
res = np.zeros(datas[0].shape)
n_data = len(datas)
for i in range(n_data):
res += datas[i] * weights[i] / n_data
return res