-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_text_tensor.m
48 lines (41 loc) · 1.09 KB
/
main_text_tensor.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function main(folder, dataname)
global L N lr powereps name
path('./tensor_toolbox_2.5/', path);
path('./emgm/', path);
stem = 0;
filter = 0;
prepare_dblp;
emptyidx = find(sum(pumat, 2) == 0);
pumat(emptyidx, :) = [];
label = load([folder 'all.label']);
label(emptyidx, :) = [];
[docnum, wordnum] = size(pumat);
fprintf('docnum %d, wordnum %d', docnum, wordnum);
%testnum = round(docnum / 5);
%y = randomsample(docnum, testnum);
%testmat = pumat(y, :);
%trainmat = pumat;
%trainmat(y, :) = [];
name = values(uname);
L = 30;
N = 30;
lr = 1.0;
powereps = 1e-5;
T = 20;
%mumap = tdgauss(pumat, T);
%mumap = mumap';
%writeflattopics('tree', mumap, 20);
%error(' ');
%pumat2 = pumat * mumap;
%[C, result] = max(pumat2, [], 2);
%
%label = load([folder 'all.label']);
%score = nmi(label, result);
%
%fprintf('score=%f\n', score);
randommat = rand(wordnum, 40);
randommat = bsxfun(@rdivide, randommat, sqrt(sum(randommat.*randommat,1)));
sm_pumat = pumat * randommat;
sm_pumat = bsxfun(@rdivide, sm_pumat, sqrt(sum(sm_pumat .*sm_pumat, 2)));
[result, model, llh] = emgm(sm_pumat', T);
score = nmi(label, result)