Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
ncd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
ncd
Commits
a8745458
Commit
a8745458
authored
Dec 16, 2021
by
ac_fx
Browse files
Options
Downloads
Patches
Plain Diff
tsneCluster
parent
a155b5e1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/MATLAB/+Cluster/SpectralCluster.m
+1
-1
1 addition, 1 deletion
src/MATLAB/+Cluster/SpectralCluster.m
src/MATLAB/+Cluster/tsneCluster.m
+29
-0
29 additions, 0 deletions
src/MATLAB/+Cluster/tsneCluster.m
src/MATLAB/apps/nist digits/goTSNE.m
+30
-0
30 additions, 0 deletions
src/MATLAB/apps/nist digits/goTSNE.m
with
60 additions
and
1 deletion
src/MATLAB/+Cluster/SpectralCluster.m
+
1
−
1
View file @
a8745458
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
% ******************************************************************************/
% ******************************************************************************/
% distance matrix A into k clusters
% distance matrix A into k clusters
function
idx
=
SpectralCluster
(
A
,
k
)
function
[
idx
,
Y
]
=
SpectralCluster
(
A
,
k
)
NREP
=
50
;
NREP
=
50
;
if
(
1
==
k
)
if
(
1
==
k
)
...
...
This diff is collapsed.
Click to expand it.
src/MATLAB/+Cluster/tsneCluster.m
0 → 100644
+
29
−
0
View file @
a8745458
% andy cohen -- Dec 16 2021
%
% tsne spectral clustering
function
[
idx
,
Y
]
=
tsneCluster
(
distanceMatrix
,
K
)
if
(
1
==
K
)
idx
=
ones
(
size
(
A
,
2
),
1
);
return
;
end
% # of reps for kmeans
NREP
=
50
;
% we use the matlab tsne with custom distance
% pass the distance matrix to our embedded function here
global
tsneGlobalDistanceMatrix
tsneGlobalDistanceMatrix
=
distanceMatrix
;
xsne
=
repmat
([
1
:
size
(
distanceMatrix
,
1
)]
'
,
1
,
K
);
Y
=
tsne
(
xsne
,
'distance'
,
@
tsneDistance
,
'numDimensions'
,
K
);
4
;
idx
=
kmeans
(
Y
,
K
,
'emptyaction'
,
'singleton'
,
'replicates'
,
NREP
);
function
d
=
tsneDistance
(
X
,
Y
)
global
tsneGlobalDistanceMatrix
for
i
=
1
:
size
(
Y
,
1
)
d
(
i
,
1
)
=
tsneGlobalDistanceMatrix
(
X
(
1
),
Y
(
i
,
1
));
end
4
;
This diff is collapsed.
Click to expand it.
src/MATLAB/apps/nist digits/goTSNE.m
0 → 100644
+
30
−
0
View file @
a8745458
% goTSNE.m
targetSize
=
100
;
tsneConfusion
=
[];
spectralConfusion
=
[];
NUMBER_OF_TRIALS
=
100
;
p
=
startParallel
(
128
);
parfor
nTrial
=
1
:
NUMBER_OF_TRIALS
target
=
[
0
:
9
];
K
=
length
(
target
);
cardinality
=
ceil
(
targetSize
/
length
(
target
));
xDigits
=
getNISTdigits
(
target
,
cardinality
);
dDigits
=
MNISTdistance
(
xDigits
);
idxSpectral
=
Cluster
.
SpectralCluster
(
dDigits
,
10
);
cx
=
updateConfusion
(
xDigits
,{},
K
,
0
,
idxSpectral
);
spectralConfusion
(:,:,
nTrial
)
=
cx
{
10
};
tic
()
[
idxTSNE
,
Y
]
=
Cluster
.
tsneCluster
(
dDigits
,
10
);
cx
=
updateConfusion
(
xDigits
,{},
K
,
0
,
idxTSNE
);
tsneConfusion
(:,:,
nTrial
)
=
cx
{
10
};
toc
()
5
;
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment