forked from layumi/Image-Text-Embedding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coco_word2_Rankloss_vgg19.m
executable file
·29 lines (21 loc) · 1.03 KB
/
coco_word2_Rankloss_vgg19.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function net = resnet52_new_hope_RankLoss()
%----------------------load pretrained model----------------------
netStruct = load('./data/vgg19_coco_batch32_pool_shift_both_drop0.5/net-epoch-70.mat') ;
net = dagnn.DagNN.loadobj(netStruct.net) ;
for i = 1:36 %img cnn
if(mod(i,2)==0)
net.params(i).learningRate= 0.02;
else net.params(i).learningRate= 0.001;
end
net.params(i).weightDecay=1;
end
net.params(1).learningRate = 0.0001;
net.addLayer('lrn1',dagnn.LRN('param',[4096,1e-8,1,0.5]),{'fc1_1bnx'},{'fc1bn_n'},{});
net.addLayer('lrn2',dagnn.LRN('param',[4096,1e-8,1,0.5]),{'fc5_2bnx'},{'fc2bn_n'},{});
%--for get harder sample
%net.addLayer('Multiple',dagnn.Multiple(),{'fc1bn_n','fc2bn_n'},{'Score'},{});
lossBlock = dagnn.RankLoss('rate',1);
net.addLayer('RankLoss',lossBlock,{'fc1bn_n','fc2bn_n'},'objective_f');
%net.conserveMemory = false;
%net.eval({'data',single(rand(224,224,3)),'data2',single(rand(1,1,20074))});
end