-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuntrustsetfind.m
More file actions
113 lines (110 loc) · 4.41 KB
/
Copy pathuntrustsetfind.m
File metadata and controls
113 lines (110 loc) · 4.41 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
%%%%%%%%%%%%%%%%%%%%%%%%%
% 这个程序用来挑伪标签中置信度不高的样本
% 返回值n_covey:置信度不高的样本位置
function [n_covey] = unshuffle_label_2(Zt, Cls, r_wj)
C = length(unique(Cls));
n_covey = [];
a1=0;
a2=0;
a3=0;
Cls_new = Cls;
for c = reshape(unique(Cls),1,C)
ny=[];
fprintf('%d',c)
X = Zt(Cls==c,:);
n = 1:sum(Cls==c);
if length(n)<=3
continue;
end
sim = zeros(length(n),length(n));
for i=1:(length(n)-1)
for j=(i+1):length(n)
fz = X(i,:)*X(j,:)';
fm = sqrt(X(i,:)*X(i,:)')*sqrt(X(j,:)*X(j,:)');
sim(i,j) = fz/fm;
end
end
abab = sort(setdiff(sim,0));
nab = floor(r_wj*length(abab));
if nab<=0
continue;
end
thr = abab(nab);
sim = sim>=thr;
pic = zeros(1,length(n));
for i=1:length(n)
pic(i) = sum(sim(i,:))+sum(sim(:,i));
end
wz = find(pic==max(pic));
if length(wz)>=1
ny = [ny,wz(1)];
wz = wz(1);
H = find(sim(wz,:)==1);
L = find(sim(:,wz)==1);
if length(H)>0
ny = [ny,H];
end
sim(wz,:) = 0;
if length(L)>0
ny = [ny,L'];
end
sim(:,wz) = 0;
while sum(sum(sim)) && (length(H)>0||length(L)>0)
h = [];
l = [];
pre = [H';L];
if length(H)>0
for i = 1:length(H)
ii = H(i); % ii = setdiff(H(i),pre); %
HH = find(sim(ii,:)==1);
HH = setdiff(HH,pre);
if length(HH)>0
ny = [ny,HH];
h = [h,HH];
end
sim(ii,:) = 0;
LL = find(sim(:,ii)==1);
LL = setdiff(LL,pre);
if length(LL)>0
ny = [ny,LL'];
l = [l;LL];
end
sim(:,ii) = 0;
pre_later = [h';l];
pre = [pre;pre_later];
end
end
if length(L)>0
for i = 1:length(L)
ii = L(i); % ii = setdiff(L(i),pre); % ii = L(i);
LL = find(sim(:,ii)==1);
LL = setdiff(LL,pre);
if length(LL)>0
ny = [ny,LL'];
l = [l;LL];
end
sim(:,ii) = 0;
HH = find(sim(ii,:)==1);
HH = setdiff(HH,pre);
if length(HH)>0
ny = [ny,HH];
h = [h,HH];
end
sim(ii,:) = 0;
pre_later = [h';l];
pre = [pre;pre_later];
end
end
H = h;
L = l;
end % 到这里应该就全部选完了,最终Xpic域Ypic就是我们选出的目标域较好的伪标签数据
end
nn_location =find(Cls==c);
no = setdiff(n,ny);
nn_cover = nn_location(no);
n_covey = [n_covey;nn_cover];
a1=a1+length(n);
a2=a2+length(no);
a3=a3+length(ny);
end
end