rcnn_pool5_to_fcX.m 956 Bytes
Newer Older
Ross Girshick's avatar
Ross Girshick committed
1
function feat = rcnn_pool5_to_fcX(feat, layer, rcnn_model)
2
3
4
5
% feat = rcnn_pool5_to_fcX(feat, layer, rcnn_model)
%   On-the-fly conversion of pool5 features to fc6 or fc7
%   using the weights and biases stored in rcnn_model.cnn.layers.

Ross Girshick's avatar
Ross Girshick committed
6
7
8
9
10
11
12
13
14
% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick
% 
% This file is part of the R-CNN code and is available 
% under the terms of the Simplified BSD License provided in 
% LICENSE. Please retain this notice and LICENSE if you use 
% this file (or any portion of it) in your project.
% ---------------------------------------------------------
Ross Girshick's avatar
Ross Girshick committed
15
16
17
18
19
20
21
22
23
24

% no-op for layer <= 5
if layer > 5
  for i = 6:layer
    % weights{1} = matrix of CNN weights [input_dim x output_dim]
    % weights{2} = column vector of biases
    feat = max(0, bsxfun(@plus, feat*rcnn_model.cnn.layers(i).weights{1}, ...
                          rcnn_model.cnn.layers(i).weights{2}'));
  end
end