mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-24 05:17:17 +00:00
rogueviz::kohonen:: bestsample -1
This commit is contained in:
parent
5ca009f58b
commit
f27017e0d5
@ -197,6 +197,7 @@ void coloring() {
|
|||||||
besttofind = false;
|
besttofind = false;
|
||||||
for(neuron& n: net) {
|
for(neuron& n: net) {
|
||||||
double bdiff = 1e20;
|
double bdiff = 1e20;
|
||||||
|
n.bestsample = -1;
|
||||||
for(auto p: sample_vdata_id) {
|
for(auto p: sample_vdata_id) {
|
||||||
double diff = vnorm(n.net, data[p.first].val);
|
double diff = vnorm(n.net, data[p.first].val);
|
||||||
if(diff < bdiff) bdiff = diff, n.bestsample = p.second;
|
if(diff < bdiff) bdiff = diff, n.bestsample = p.second;
|
||||||
@ -205,7 +206,10 @@ void coloring() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<cells; i++) {
|
for(int i=0; i<cells; i++) {
|
||||||
part(net[i].where->landparam_color, pid) = part(vdata[net[i].bestsample].cp.color1, pid+1);
|
if(net[i].bestsample >= 0)
|
||||||
|
part(net[i].where->landparam_color, pid) = part(vdata[net[i].bestsample].cp.color1, pid+1);
|
||||||
|
else
|
||||||
|
part(net[i].where->landparam_color, pid) = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,6 +1196,7 @@ void do_classify() {
|
|||||||
if(bdiffn.empty()) {
|
if(bdiffn.empty()) {
|
||||||
printf("Finding samples...\n");
|
printf("Finding samples...\n");
|
||||||
bdiffn.resize(cells, 1e20);
|
bdiffn.resize(cells, 1e20);
|
||||||
|
for(int i=0; i<cells; i++) net[i].bestsample = -1;
|
||||||
for(int s=0; s<samples; s++) {
|
for(int s=0; s<samples; s++) {
|
||||||
int n = bids[s];
|
int n = bids[s];
|
||||||
double diff = bdiffs[s];
|
double diff = bdiffs[s];
|
||||||
@ -1322,7 +1327,8 @@ void klistsamples(const string& fname_samples, bool best, bool colorformat) {
|
|||||||
if(best)
|
if(best)
|
||||||
for(int n=0; n<cells; n++) {
|
for(int n=0; n<cells; n++) {
|
||||||
if(!net[n].allsamples && !net[n].drawn_samples) { if(!colorformat) fprintf(f, "\n"); continue; }
|
if(!net[n].allsamples && !net[n].drawn_samples) { if(!colorformat) fprintf(f, "\n"); continue; }
|
||||||
klistsample(net[n].bestsample, n);
|
if(net[n].bestsample >= 0)
|
||||||
|
klistsample(net[n].bestsample, n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for(auto p: sample_vdata_id) {
|
for(auto p: sample_vdata_id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user