权重归一化 MATLAB

为了不让 MATLAB exp 计算崩溃,通常使用 log 进行归一化

function [w_normal]= normaliseW_func(wLogs)
%normaliseW_func(): normalise weights
%INPUT: 
% wLogs: weights.log
%OUTPUT:
% w_normal: normalised weights
log_scale= wLogs-max(wLogs); % 缩放
w_scale= exp(log_scale);
w_normal= w_scale/sum(w_scale);

end

  

 感谢 https://www.cnblogs.com/sunny99/ sumoier对本文的帮助

posted @ 2024-05-23 14:42  20岁博客少女  阅读(7)  评论(0编辑  收藏  举报