DiSMEC++
|
This class is used as an implementation detail to capture the common code of PartialModelSaver and PartialModelLoader. More...
#include <model-io.h>
Public Member Functions | |
long | num_labels () const noexcept |
Gets the total number of labels. More... | |
long | num_features () const noexcept |
Gets the total number of features. More... | |
Protected Types | |
using | weight_file_iter_t = std::vector< WeightFileEntry >::const_iterator |
Protected Member Functions | |
PartialModelIO ()=default | |
~PartialModelIO ()=default | |
void | read_metadata_file (const path &meta_file) |
void | insert_sub_file (const WeightFileEntry &data) |
Inserts a new sub-file entry into the metadata object. More... | |
weight_file_iter_t | label_lower_bound (label_id_t pos) const |
Gets an iterator into the weight-file list that points to the first element whose starting label is larger than or equal to pos . More... | |
Protected Attributes | |
long | m_TotalLabels = -1 |
long | m_NumFeatures = -1 |
std::vector< WeightFileEntry > | m_SubFiles |
This class is used as an implementation detail to capture the common code of PartialModelSaver and PartialModelLoader.
Definition at line 151 of file model-io.h.
|
protected |
Definition at line 177 of file model-io.h.
|
protecteddefault |
|
protecteddefault |
|
protected |
Inserts a new sub-file entry into the metadata object.
data | The specifications of the sub file to be added. |
std::logic_error | if data has weights for labels that overlap with already existing weights. |
Definition at line 123 of file model-io.cpp.
References dismec::io::model::WeightFileEntry::FileName, dismec::io::model::WeightFileEntry::First, and dismec::opaque_int_type< Tag, T >::to_index().
|
protected |
Gets an iterator into the weight-file list that points to the first element whose starting label is larger than or equal to pos
.
Assuming the partial model contains the weights for the label ranges [20, 50)
and [100, 150)
. Then label_lower_bound(label)
will return an iterator to the first element for all label
values in the range [00, 20]
, the second for the range (20, 100]
and an iterator to end for all others. This corresponds to the position in front of which a new sub-model for label pos
would have to be inserted.
Definition at line 116 of file model-io.cpp.
References dismec::io::model::WeightFileEntry::First.
Referenced by dismec::io::model::PartialModelSaver::any_weight_vector_for_interval(), and TEST_CASE().
|
inlinenoexcept |
Gets the total number of features.
If this value is unknown (i.e. if there hasn't been one model submitted yet), -1 is returned. For a model reader, this is always a positive value.
Definition at line 165 of file model-io.h.
References m_NumFeatures.
Referenced by dismec::io::model::PartialModelLoader::load_model().
|
inlinenoexcept |
Gets the total number of labels.
If this value is unknown (i.e. if there hasn't been one model submitted yet), -1 is returned. For a model reader, this is always a positive value.
Definition at line 158 of file model-io.h.
References m_TotalLabels.
Referenced by dismec::io::model::PartialModelLoader::load_model(), and TrainingProgram::parse_label_range().
|
protected |
Definition at line 93 of file model-io.cpp.
References m_NumFeatures, m_SubFiles, m_TotalLabels, and dismec::io::model::parse_weights_format().
Referenced by dismec::io::model::PartialModelLoader::PartialModelLoader(), and dismec::io::model::PartialModelSaver::PartialModelSaver().
|
protected |
Definition at line 174 of file model-io.h.
Referenced by dismec::io::model::PartialModelSaver::add_model(), dismec::io::model::PartialModelLoader::load_model(), num_features(), read_metadata_file(), and dismec::io::model::PartialModelSaver::update_meta_file().
|
protected |
Definition at line 176 of file model-io.h.
Referenced by dismec::io::model::PartialModelSaver::any_weight_vector_for_interval(), dismec::io::model::PartialModelSaver::finalize(), dismec::io::model::PartialModelSaver::get_missing_weights(), dismec::io::model::PartialModelLoader::load_model(), dismec::io::model::PartialModelLoader::num_weight_files(), read_metadata_file(), TEST_CASE(), dismec::io::model::PartialModelSaver::update_meta_file(), and dismec::io::model::PartialModelLoader::validate().
|
protected |
Definition at line 173 of file model-io.h.
Referenced by dismec::io::model::PartialModelSaver::add_model(), dismec::io::model::PartialModelSaver::finalize(), dismec::io::model::PartialModelSaver::get_missing_weights(), dismec::io::model::PartialModelLoader::load_model(), num_labels(), read_metadata_file(), and dismec::io::model::PartialModelSaver::update_meta_file().