Trains the Algorithm Parameter: _xmippDS Data structure to train, a codeBook in this case Parameter: _examples A training set with the training examples
Trains the algorithm Parameter: _xmippDS Data structure to train, a codeBook in this case Parameter: _examples A training set with the training examples
50 if (verbosity == 1 || verbosity == 3)
60 unsigned numClusters = _xmippDS.
size();
61 unsigned numVectors = _examples.size();
77 std::vector<FeatureVector> alpha;
78 alpha.resize(numVectors);
79 for (vv = 0; vv < numVectors; vv++)
80 alpha[vv].resize(numClusters, 0.);
83 double Deltam = (double)(
m - 1.) / (double)
epochs;
91 double mt = (
m - t * Deltam);
92 if ((mt - 1.) <= 1e-2)
95 auxExp = 2. / (mt - 1.);
100 tmpD.resize(numClusters);
101 for (k = 0; k < numVectors; k++)
104 for (i = 0; i < numClusters; i ++)
107 for (
size_t d = 0;
d < _examples.theItems[0].size();
d++)
108 auxDist += ((
double)(_examples.theItems[
k][
d]) - (
double)(_xmippDS.
theItems[
i][
d])) * ((double)(_examples.theItems[k][
d]) - (double)(_xmippDS.
theItems[i][d]));
109 auxDist = (double)
sqrt((
double)auxDist);
110 auxDist = (double) pow((
double) auxDist, (double) auxExp);
112 if (std::isnan(auxDist)) auxDist =
MAXZERO;
113 if (!finite(auxDist)) auxDist = 1e200;
114 auxProd += 1. / auxDist;
117 for (j = 0; j < numClusters; j ++)
126 for (cc = 0; cc < numClusters; cc++)
127 for (vv = 0; vv < numVectors; vv++)
128 alpha[vv][cc] = (
floatFeature) pow((
double)_xmippDS.
memb[vv][cc], (
double)mt);
134 for (cc = 0; cc < numClusters; cc++)
136 std::vector<double> tmpV;
137 tmpV.resize(_examples.theItems[0].size(), 0.);
139 for (vv = 0; vv < numVectors; vv++)
141 for (j = 0; j < _examples.theItems[0].size(); j++)
142 tmpV[j] += (
double)((double)(alpha[vv][cc]) * ((double)(_examples.theItems[vv][j]) - (double)(_xmippDS.
theItems[cc][j])));
143 auxSum += (double)(alpha[vv][cc]);
146 for (j = 0; j < _examples.theItems[0].size(); j++)
153 for (i = 0; i < numClusters; i ++)
156 stopError += auxError * auxError;
164 if (verbosity == 1 || verbosity == 3)
169 sprintf(s,
"Iteration %d of %d. Code vectors variation: %g\n", t,
epochs, stopError);
175 if (verbosity == 1 || verbosity == 3)
double euclideanDistance(const std::vector< T > &_v1, const std::vector< T > &_v2)
MM memb
Alias for Fuzzy vectors.
void sqrt(Image< double > &op)
virtual void OnReportOperation(const std::string &_rsOp)=0
virtual void OnInitOperation(unsigned long _est_it)=0
virtual const unsigned & getVerbosity() const
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
std::vector< Item > theItems
virtual void OnProgress(unsigned long _it)=0
std::vector< floatFeature > FeatureVector