DiSMEC++
dismec::io::model::PartialModelIO Class Reference

This class is used as an implementation detail to capture the common code of PartialModelSaver and PartialModelLoader. More...

#include <model-io.h>

Inheritance diagram for dismec::io::model::PartialModelIO:
dismec::io::model::PartialModelLoader dismec::io::model::PartialModelSaver

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< WeightFileEntrym_SubFiles
 

Detailed Description

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.

Member Typedef Documentation

◆ weight_file_iter_t

using dismec::io::model::PartialModelIO::weight_file_iter_t = std::vector<WeightFileEntry>::const_iterator
protected

Definition at line 177 of file model-io.h.

Constructor & Destructor Documentation

◆ PartialModelIO()

dismec::io::model::PartialModelIO::PartialModelIO ( )
protecteddefault

◆ ~PartialModelIO()

dismec::io::model::PartialModelIO::~PartialModelIO ( )
protecteddefault

Member Function Documentation

◆ insert_sub_file()

void dismec::io::model::PartialModelIO::insert_sub_file ( const WeightFileEntry data)
protected

Inserts a new sub-file entry into the metadata object.

Parameters
dataThe specifications of the sub file to be added.
Exceptions
std::logic_errorif 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().

◆ label_lower_bound()

auto dismec::io::model::PartialModelIO::label_lower_bound ( label_id_t  pos) const
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().

◆ num_features()

long dismec::io::model::PartialModelIO::num_features ( ) const
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().

◆ num_labels()

long dismec::io::model::PartialModelIO::num_labels ( ) const
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().

◆ read_metadata_file()

void PartialModelIO::read_metadata_file ( const path &  meta_file)
protected

Member Data Documentation

◆ m_NumFeatures

◆ m_SubFiles

◆ m_TotalLabels


The documentation for this class was generated from the following files: