DiSMEC++
anonymous_namespace{model-io.cpp} Namespace Reference

Functions

void save_weights_dispatch (std::ostream &target, const Model &model, SaveOption &options)
 This function calls on of the save functions, depending on the format specified on options More...
 
void read_weights_dispatch (std::istream &source, WeightFormat format, Model &model)
 This function calls the reads function that corresponds to the given weight format. More...
 
std::shared_ptr< Modelmake_model (long num_features, ::model::PartialModelSpec spec, bool sparse)
 
bool use_sparse_weights (PartialModelLoader::ESparseMode mode, WeightFormat format)
 

Variables

const std::array< const char *, 4 > weight_format_names
 Translation from io::model::WeightFormat to std::string. More...
 
const std::array< bool, 4 > weight_format_sparsity
 Lookup which mode has sparse weights. More...
 

Function Documentation

◆ make_model()

std::shared_ptr<Model> anonymous_namespace{model-io.cpp}::make_model ( long  num_features,
::model::PartialModelSpec  spec,
bool  sparse 
)

Definition at line 400 of file model-io.cpp.

Referenced by dismec::io::model::PartialModelLoader::load_model().

◆ read_weights_dispatch()

void anonymous_namespace{model-io.cpp}::read_weights_dispatch ( std::istream &  source,
WeightFormat  format,
Model model 
)

This function calls the reads function that corresponds to the given weight format.

Parameters
sourceStream from which the data is read.
formatData format used to interpret source.
modelModel in which the weights will be stored. Must already have allocated enough space to store the weights.

Definition at line 67 of file model-io.cpp.

References dismec::io::model::DENSE_NPY, dismec::io::model::DENSE_TXT, dismec::io::model::load_dense_weights_npy(), dismec::io::model::load_dense_weights_txt(), dismec::io::model::load_sparse_weights_txt(), and dismec::io::model::SPARSE_TXT.

Referenced by dismec::io::model::PartialModelLoader::load_model().

◆ save_weights_dispatch()

void anonymous_namespace{model-io.cpp}::save_weights_dispatch ( std::ostream &  target,
const Model model,
SaveOption options 
)

This function calls on of the save functions, depending on the format specified on options

Parameters
targetStream where to save the weights.
modelThe model whose weights will be saved.
optionsSaving options. The format of the save file depends on this.

Definition at line 43 of file model-io.cpp.

References dismec::io::model::SaveOption::Culling, dismec::io::model::DENSE_NPY, dismec::io::model::DENSE_TXT, dismec::io::model::SaveOption::Format, dismec::io::model::NULL_FORMAT, dismec::io::model::SaveOption::Precision, dismec::io::model::save_as_sparse_weights_txt(), dismec::io::model::save_dense_weights_npy(), dismec::io::model::save_dense_weights_txt(), and dismec::io::model::SPARSE_TXT.

◆ use_sparse_weights()

Variable Documentation

◆ weight_format_names

const std::array<const char*, 4> anonymous_namespace{model-io.cpp}::weight_format_names
Initial value:
= {
"DenseTXT", "SparseTXT", "DenseNPY", "<NULL>"
}

Translation from io::model::WeightFormat to std::string.

Definition at line 28 of file model-io.cpp.

Referenced by dismec::io::model::parse_weights_format(), and dismec::io::model::to_string().

◆ weight_format_sparsity

const std::array<bool, 4> anonymous_namespace{model-io.cpp}::weight_format_sparsity
Initial value:
= {
false, true, false, true
}

Lookup which mode has sparse weights.

Definition at line 33 of file model-io.cpp.

Referenced by use_sparse_weights().