function [pooled_mat, card_vec] = pool_config_multi( code_mat, ind_vec, M, Method )
%% POOL_CONFIG_MULTI: pool multi-channels in configuration space;
%==========================================================================
% Input_Args:
% <code_mat> ~ [ N, K ];
% <ind_vec> ~ [ N, 1 ];
% <M>: the number of channels;
% <Method>: 'sum', 'ave', 'max';
%
% Output_Args:
% <pooled_mat> ~ [ M, K ];
% <card_vec> ~ [ M, 1 ];
%
% Cross-Reference Information:
% Called by [doFeatPooling];
% [doFeatPoolingForPoolDimReduct]
% Calling: NULL;
%
%==========================================================================
% modified on 2012/4/17 by Jun Zhu and Weijia Zou;
% For any question, please contact: junnyzhu@sjtu.edu.cn or zouweijia@sjtu.edu.cn
%%
N = size(code_mat,1);
K = size(code_mat,2);
if isempty(code_mat)
pooled_mat = zeros( [M,K] );
card_vec = zeros( [M,1] );
return;
end
switch Method
case 'sum'
[ pooled_mat, card_vec ] = sum_pooling_multi( code_mat, ind_vec, K, M );
case 'ave'
[ pooled_mat, card_vec ] = ave_pooling_multi( code_mat, ind_vec, K, M );
case 'max'
[ pooled_mat, card_vec ] = max_pooling_multi( code_mat, ind_vec, K, M );
otherwise
error('Unknown method on feature pooling;\n');
end
if sum(card_vec) ~= N
error('The number of pooled patches does not match;\n');
end
end % end of function;
%% for 'sum' pooling
function [ pooled_mat, card_vec ] = sum_pooling_multi( code_mat, ind_vec, K, M )
pooled_mat = zeros( [M,K] );
card_vec = zeros( [M,1] );
for i = 1: M
indices_found = find( ind_vec == i );
if isempty(indices_found)
continue;
end
pooled_mat(i,:) = sum( code_mat( indices_found, : ), 1 );
card_vec(i) = length( indices_found );
end % i;
end % end of function;
%% for 'ave' pooling
function [ pooled_mat, card_vec ] = ave_pooling_multi( code_mat, ind_vec, K, M )
pooled_mat = zeros( [M,K] );
card_vec = zeros( [M,1] );
for i = 1: M
indices_found = find( ind_vec == i );
if isempty(indices_found)
continue;
end
pooled_mat(i,:) = mean( code_mat( indices_found, : ), 1 );
card_vec(i) = length( indices_found );
end % i;
end % end of function;
%% for 'max' pooling
function [ pooled_mat, card_vec ] = max_pooling_multi( code_mat, ind_vec, K, M )
pooled_mat = zeros( [M,K] );
card_vec = zeros( [M,1] );
for i = 1: M
indices_found = find( ind_vec == i );
if isempty(indices_found)
continue;
end
pooled_mat(i,:) = max( code_mat( indices_found, : ), [], 1 );
card_vec(i) = length( indices_found );
end % i;
end % end of function;
没有合适的资源?快使用搜索试试~ 我知道了~
pool_config_multi.zip_SUM_max pooling_pooling
共1个文件
m:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 77 浏览量
2022-07-14
08:48:28
上传
评论
收藏 885B ZIP 举报
温馨提示
sum pooling, max pooling, average pooling,三种 Feature Coding pooling方法
资源详情
资源评论
资源推荐
收起资源包目录
pool_config_multi.zip (1个子文件)
pool_config_multi.m 3KB
共 1 条
- 1
刘良运
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0