本文整理汇总了C++中ISamples::next方法的典型用法代码示例。如果您正苦于以下问题:C++ ISamples::next方法的具体用法?C++ ISamples::next怎么用?C++ ISamples::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISamples
的用法示例。
在下文中一共展示了ISamples::next方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: norm
void ISNorm::norm (ISamples &samples) {
samples.reset ();
ssi_sample_t *sample = 0;
while (sample = samples.next ()) {
norm (*sample);
}
}
示例2: write
bool FileSamplesOut::write (ISamples &data) {
data.reset ();
ssi_sample_t *sample = 0;
while (sample = data.next ()) {
write (*sample);
}
return true;
}
示例3: eval
void Evaluation::eval (IFusion &fusion, ssi_size_t n_models, IModel **models, ISamples &samples) {
// init confussion matrix
_trainer = 0;
destroy_conf_mat ();
init_conf_mat (samples);
ssi_size_t n_classes = samples.getClassSize ();
ssi_real_t *probs = new ssi_real_t[n_classes];
_n_total = samples.getSize ();
_result_vec = new ssi_size_t[2*_n_total];
_result_vec_ptr = _result_vec;
samples.reset ();
const ssi_sample_t *sample = 0;
while (sample = samples.next ()) {
ssi_size_t real_index = sample->class_id;
*_result_vec_ptr++ = real_index;
if (fusion.forward (n_models, models, sample->num, sample->streams, n_classes, probs)) {
ssi_size_t max_ind = 0;
ssi_real_t max_val = probs[0];
for (ssi_size_t i = 1; i < n_classes; i++) {
if (probs[i] > max_val) {
max_val = probs[i];
max_ind = i;
}
}
*_result_vec_ptr++ = max_ind;
_conf_mat_ptr[real_index][max_ind]++;
_n_classified++;
} else if (!_allow_unclassified) {
ssi_size_t max_ind = _default_class_id;
*_result_vec_ptr++ = max_ind;
_conf_mat_ptr[real_index][max_ind]++;
_n_classified++;
} else {
*_result_vec_ptr++ = SSI_ISAMPLES_GARBAGE_CLASS_ID;
_n_unclassified++;
}
}
delete[] probs;
}
示例4: train
bool MyModel::train (ISamples &samples,
ssi_size_t stream_index) {
if (samples.getSize () == 0) {
ssi_wrn ("empty sample list");
return false;
}
if (isTrained ()) {
ssi_wrn ("already trained");
return false;
}
_n_classes = samples.getClassSize ();
_n_features = samples.getStream (stream_index).dim;
_centers = new ssi_real_t *[_n_classes];
for (ssi_size_t i = 0; i < _n_classes; i++) {
_centers[i] = new ssi_real_t[_n_features];
for (ssi_size_t j = 0; j < _n_features; j++) {
_centers[i][j] = 0;
}
}
ssi_sample_t *sample;
samples.reset ();
ssi_real_t *ptr = 0;
while (sample = samples.next ()) {
ssi_size_t id = sample->class_id;
ptr = ssi_pcast (ssi_real_t, sample->streams[stream_index]->ptr);
for (ssi_size_t j = 0; j < _n_features; j++) {
_centers[id][j] += ptr[j];
}
}
for (ssi_size_t i = 0; i < _n_classes; i++) {
ssi_size_t num = samples.getSize (i);
for (ssi_size_t j = 0; j < _n_features; j++) {
_centers[i][j] /= num;
}
}
return true;
}
示例5: train
bool SimpleKNN::train (ISamples &samples,
ssi_size_t stream_index) {
if (samples.getSize () == 0) {
ssi_wrn ("empty sample list");
return false;
}
if (samples.getSize () < _options.k) {
ssi_wrn ("sample list has less than '%u' entries", _options.k);
return false;
}
if (isTrained ()) {
ssi_wrn ("already trained");
return false;
}
_n_classes = samples.getClassSize ();
_n_samples = samples.getSize ();
_n_features = samples.getStream (stream_index).dim;
_data = new ssi_real_t[_n_features*_n_samples];
_classes = new ssi_size_t[_n_samples];
ssi_sample_t *sample;
samples.reset ();
ssi_real_t *data_ptr = _data;
ssi_size_t *class_ptr = _classes;
ssi_stream_t *stream_ptr = 0;
ssi_size_t bytes_to_copy = _n_features * sizeof (ssi_real_t);
while (sample = samples.next ()) {
memcpy (data_ptr, sample->streams[stream_index]->ptr, bytes_to_copy);
*class_ptr++ = sample->class_id;
data_ptr += _n_features;
}
return true;
}
示例6: eval_h
void Evaluation::eval_h (ISamples &samples) {
// walk through sample list and test trainer against each sample
samples.reset ();
const ssi_sample_t *sample = 0;
ssi_size_t index, real_index;
while (sample = samples.next ()) {
real_index = sample->class_id;
*_result_vec_ptr++ = real_index;
if (_trainer->forward (sample->num, sample->streams, index)) {
*_result_vec_ptr++ = index;
_conf_mat_ptr[real_index][index]++;
_n_classified++;
} else if (!_allow_unclassified) {
index = _default_class_id;
*_result_vec_ptr++ = index;
_conf_mat_ptr[real_index][index]++;
_n_classified++;
} else {
*_result_vec_ptr++ = SSI_ISAMPLES_GARBAGE_CLASS_ID;
_n_unclassified++;
}
}
}