switch to serialize() and use boost::serialization
The commit replaces Serialize() with serialize() for files inside mlpack/methods/(r* or s*). This also replaces data::CreateNVP(member, "member") with BOOST_SERIALIZATION_NVP(member). The current changes are required since we have moved to using boost serialization and plan to drop serialization shim.
This commit is contained in:
@@ -85,7 +85,7 @@ class LMetric
|
||||
|
||||
//! Serialize the metric (nothing to do).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
|
||||
//! The power of the metric.
|
||||
static const int Power = TPower;
|
||||
|
||||
@@ -548,7 +548,7 @@ class BinarySpaceTree
|
||||
* Serialize the tree.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
};
|
||||
|
||||
} // namespace tree
|
||||
|
||||
@@ -942,7 +942,7 @@ template<typename MetricType,
|
||||
class SplitType>
|
||||
template<typename Archive>
|
||||
void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
|
||||
Serialize(Archive& ar, const unsigned int /* version */)
|
||||
serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class AdaBoost
|
||||
* Serialize the AdaBoost model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! The number of classes in the model.
|
||||
|
||||
@@ -238,13 +238,13 @@ void AdaBoost<WeakLearnerType, MatType>::Classify(
|
||||
*/
|
||||
template<typename WeakLearnerType, typename MatType>
|
||||
template<typename Archive>
|
||||
void AdaBoost<WeakLearnerType, MatType>::Serialize(Archive& ar,
|
||||
void AdaBoost<WeakLearnerType, MatType>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(numClasses, "classes");
|
||||
ar & data::CreateNVP(tolerance, "tolerance");
|
||||
ar & data::CreateNVP(ztProduct, "ztProduct");
|
||||
ar & data::CreateNVP(alpha, "alpha");
|
||||
ar & BOOST_SERIALIZATION_NVP(numClasses);
|
||||
ar & BOOST_SERIALIZATION_NVP(tolerance);
|
||||
ar & BOOST_SERIALIZATION_NVP(ztProduct);
|
||||
ar & BOOST_SERIALIZATION_NVP(alpha);
|
||||
|
||||
// Now serialize each weak learner.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -252,12 +252,7 @@ void AdaBoost<WeakLearnerType, MatType>::Serialize(Archive& ar,
|
||||
wl.clear();
|
||||
wl.resize(alpha.size());
|
||||
}
|
||||
for (size_t i = 0; i < wl.size(); ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "weakLearner" << i;
|
||||
ar & data::CreateNVP(wl[i], oss.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(wl);
|
||||
}
|
||||
|
||||
} // namespace adaboost
|
||||
|
||||
@@ -86,7 +86,7 @@ class AdaBoostModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -99,13 +99,13 @@ class AdaBoostModel
|
||||
pBoost = NULL;
|
||||
}
|
||||
|
||||
ar & data::CreateNVP(mappings, "mappings");
|
||||
ar & data::CreateNVP(weakLearnerType, "weakLearnerType");
|
||||
ar & BOOST_SERIALIZATION_NVP(mappings);
|
||||
ar & BOOST_SERIALIZATION_NVP(weakLearnerType);
|
||||
if (weakLearnerType == WeakLearnerTypes::DECISION_STUMP)
|
||||
ar & data::CreateNVP(dsBoost, "adaboost_ds");
|
||||
ar & BOOST_SERIALIZATION_NVP(dsBoost);
|
||||
else if (weakLearnerType == WeakLearnerTypes::PERCEPTRON)
|
||||
ar & data::CreateNVP(pBoost, "adaboost_p");
|
||||
ar & data::CreateNVP(dimensionality, "dimensionality");
|
||||
ar & BOOST_SERIALIZATION_NVP(pBoost);
|
||||
ar & BOOST_SERIALIZATION_NVP(dimensionality);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class AverageInitialization
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to do).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -61,10 +61,10 @@ class GivenInitialization
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(w, "w");
|
||||
ar & data::CreateNVP(h, "h");
|
||||
ar & BOOST_SERIALIZATION_NVP(w);
|
||||
ar & BOOST_SERIALIZATION_NVP(h);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -85,7 +85,7 @@ class RandomAcolInitialization
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -53,7 +53,7 @@ class RandomInitialization
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -120,7 +120,7 @@ class NMFALSUpdate
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
}; // class NMFALSUpdate
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -98,7 +98,7 @@ class NMFMultiplicativeDistanceUpdate
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -151,7 +151,7 @@ class NMFMultiplicativeDivergenceUpdate
|
||||
|
||||
//! Serialize the object (in this case, there is nothing to serialize).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace amf
|
||||
|
||||
@@ -166,15 +166,14 @@ class SVDBatchLearning
|
||||
|
||||
//! Serialize the SVDBatch object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
ar & CreateNVP(u, "u");
|
||||
ar & CreateNVP(kw, "kw");
|
||||
ar & CreateNVP(kh, "kh");
|
||||
ar & CreateNVP(momentum, "momentum");
|
||||
ar & CreateNVP(mW, "mW");
|
||||
ar & CreateNVP(mH, "mH");
|
||||
ar & BOOST_SERIALIZATION_NVP(u);
|
||||
ar & BOOST_SERIALIZATION_NVP(kw);
|
||||
ar & BOOST_SERIALIZATION_NVP(kh);
|
||||
ar & BOOST_SERIALIZATION_NVP(momentum);
|
||||
ar & BOOST_SERIALIZATION_NVP(mW);
|
||||
ar & BOOST_SERIALIZATION_NVP(mH);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -217,7 +217,7 @@ class FFN
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
/**
|
||||
* Perform the forward pass of the data in real batch mode.
|
||||
|
||||
@@ -394,14 +394,14 @@ void FFN<OutputLayerType, InitializationRuleType>::Gradient()
|
||||
|
||||
template<typename OutputLayerType, typename InitializationRuleType>
|
||||
template<typename Archive>
|
||||
void FFN<OutputLayerType, InitializationRuleType>::Serialize(
|
||||
void FFN<OutputLayerType, InitializationRuleType>::serialize(
|
||||
Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(parameter, "parameter");
|
||||
ar & data::CreateNVP(width, "width");
|
||||
ar & data::CreateNVP(height, "height");
|
||||
ar & data::CreateNVP(currentInput, "currentInput");
|
||||
ar & data::CreateNVP(currentTarget, "currentTarget");
|
||||
ar & BOOST_SERIALIZATION_NVP(parameter);
|
||||
ar & BOOST_SERIALIZATION_NVP(width);
|
||||
ar & BOOST_SERIALIZATION_NVP(height);
|
||||
ar & BOOST_SERIALIZATION_NVP(currentInput);
|
||||
ar & BOOST_SERIALIZATION_NVP(currentTarget);
|
||||
|
||||
// Be sure to clear other layers before loading.
|
||||
if (Archive::is_loading::value)
|
||||
|
||||
@@ -209,7 +209,7 @@ class RNN
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
private:
|
||||
// Helper functions.
|
||||
/**
|
||||
|
||||
@@ -409,16 +409,16 @@ void RNN<OutputLayerType, InitializationRuleType>::Gradient()
|
||||
|
||||
template<typename OutputLayerType, typename InitializationRuleType>
|
||||
template<typename Archive>
|
||||
void RNN<OutputLayerType, InitializationRuleType>::Serialize(
|
||||
void RNN<OutputLayerType, InitializationRuleType>::serialize(
|
||||
Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(parameter, "parameter");
|
||||
ar & data::CreateNVP(rho, "rho");
|
||||
ar & data::CreateNVP(single, "single");
|
||||
ar & data::CreateNVP(inputSize, "inputSize");
|
||||
ar & data::CreateNVP(outputSize, "outputSize");
|
||||
ar & data::CreateNVP(targetSize, "targetSize");
|
||||
ar & data::CreateNVP(currentInput, "currentInput");
|
||||
ar & BOOST_SERIALIZATION_NVP(parameter);
|
||||
ar & BOOST_SERIALIZATION_NVP(rho);
|
||||
ar & BOOST_SERIALIZATION_NVP(single);
|
||||
ar & BOOST_SERIALIZATION_NVP(inputSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(outputSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(targetSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(currentInput);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
|
||||
@@ -120,16 +120,16 @@ class ApproxKFNModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(type, "type");
|
||||
ar & BOOST_SERIALIZATION_NVP(type);
|
||||
if (type == 0)
|
||||
{
|
||||
ar & data::CreateNVP(ds, "model");
|
||||
ar & BOOST_SERIALIZATION_NVP(ds);
|
||||
}
|
||||
else
|
||||
{
|
||||
ar & data::CreateNVP(qdafn, "model");
|
||||
ar & BOOST_SERIALIZATION_NVP(qdafn);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,7 +97,7 @@ class DrusillaSelect
|
||||
* Serialize the model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Access the candidate set.
|
||||
const MatType& CandidateSet() const { return candidateSet; }
|
||||
|
||||
@@ -201,15 +201,13 @@ void DrusillaSelect<MatType>::Search(const MatType& querySet,
|
||||
//! Serialize the model.
|
||||
template<typename MatType>
|
||||
template<typename Archive>
|
||||
void DrusillaSelect<MatType>::Serialize(Archive& ar,
|
||||
void DrusillaSelect<MatType>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(candidateSet, "candidateSet");
|
||||
ar & CreateNVP(candidateIndices, "candidateIndices");
|
||||
ar & CreateNVP(l, "l");
|
||||
ar & CreateNVP(m, "m");
|
||||
ar & BOOST_SERIALIZATION_NVP(candidateSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(candidateIndices);
|
||||
ar & BOOST_SERIALIZATION_NVP(l);
|
||||
ar & BOOST_SERIALIZATION_NVP(m);
|
||||
}
|
||||
|
||||
} // namespace neighbor
|
||||
|
||||
@@ -81,7 +81,7 @@ class QDAFN
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Get the number of projections.
|
||||
size_t NumProjections() const { return candidateSet.size(); }
|
||||
|
||||
@@ -171,19 +171,17 @@ void QDAFN<MatType>::Search(const MatType& querySet,
|
||||
|
||||
template<typename MatType>
|
||||
template<typename Archive>
|
||||
void QDAFN<MatType>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void QDAFN<MatType>::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(l, "l");
|
||||
ar & CreateNVP(m, "m");
|
||||
ar & CreateNVP(lines, "lines");
|
||||
ar & CreateNVP(projections, "projections");
|
||||
ar & CreateNVP(sIndices, "sIndices");
|
||||
ar & CreateNVP(sValues, "sValues");
|
||||
ar & BOOST_SERIALIZATION_NVP(l);
|
||||
ar & BOOST_SERIALIZATION_NVP(m);
|
||||
ar & BOOST_SERIALIZATION_NVP(lines);
|
||||
ar & BOOST_SERIALIZATION_NVP(projections);
|
||||
ar & BOOST_SERIALIZATION_NVP(sIndices);
|
||||
ar & BOOST_SERIALIZATION_NVP(sValues);
|
||||
if (Archive::is_loading::value)
|
||||
candidateSet.clear();
|
||||
ar & CreateNVP(candidateSet, "candidateSet");
|
||||
ar & BOOST_SERIALIZATION_NVP(candidateSet);
|
||||
}
|
||||
|
||||
} // namespace neighbor
|
||||
|
||||
@@ -248,7 +248,7 @@ class CF
|
||||
* Serialize the CF model to the given archive.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Number of users for similarity.
|
||||
|
||||
@@ -155,17 +155,15 @@ void CF::Train(const arma::sp_mat& data,
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void CF::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void CF::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
// This model is simple; just serialize all the members. No special handling
|
||||
// required.
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(numUsersForSimilarity, "numUsersForSimilarity");
|
||||
ar & CreateNVP(rank, "rank");
|
||||
ar & CreateNVP(w, "w");
|
||||
ar & CreateNVP(h, "h");
|
||||
ar & CreateNVP(cleanedData, "cleanedData");
|
||||
ar & BOOST_SERIALIZATION_NVP(numUsersForSimilarity);
|
||||
ar & BOOST_SERIALIZATION_NVP(rank);
|
||||
ar & BOOST_SERIALIZATION_NVP(w);
|
||||
ar & BOOST_SERIALIZATION_NVP(h);
|
||||
ar & BOOST_SERIALIZATION_NVP(cleanedData);
|
||||
}
|
||||
|
||||
} // namespace cf
|
||||
|
||||
@@ -131,7 +131,7 @@ class DecisionStump
|
||||
|
||||
//! Serialize the decision stump.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! The number of classes (we must store this for boosting).
|
||||
|
||||
@@ -198,18 +198,16 @@ DecisionStump<MatType>::DecisionStump(const DecisionStump<>& other,
|
||||
*/
|
||||
template<typename MatType>
|
||||
template<typename Archive>
|
||||
void DecisionStump<MatType>::Serialize(Archive& ar,
|
||||
void DecisionStump<MatType>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// This is straightforward; just serialize all of the members of the class.
|
||||
// None need special handling.
|
||||
ar & CreateNVP(numClasses, "classes");
|
||||
ar & CreateNVP(bucketSize, "bucketSize");
|
||||
ar & CreateNVP(splitDimension, "splitDimension");
|
||||
ar & CreateNVP(split, "split");
|
||||
ar & CreateNVP(binLabels, "binLabels");
|
||||
ar & BOOST_SERIALIZATION_NVP(numClasses);
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(splitDimension);
|
||||
ar & BOOST_SERIALIZATION_NVP(split);
|
||||
ar & BOOST_SERIALIZATION_NVP(binLabels);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,10 +86,10 @@ struct DSModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(mappings, "mappings");
|
||||
ar & data::CreateNVP(stump, "stump");
|
||||
ar & BOOST_SERIALIZATION_NVP(mappings);
|
||||
ar & BOOST_SERIALIZATION_NVP(stump);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ class DecisionTree :
|
||||
* Serialize the tree.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Get the number of children.
|
||||
size_t NumChildren() const { return children.size(); }
|
||||
|
||||
@@ -932,11 +932,9 @@ void DecisionTree<FitnessFunction,
|
||||
CategoricalSplitType,
|
||||
DimensionSelectionType,
|
||||
ElemType,
|
||||
NoRecursion>::Serialize(Archive& ar,
|
||||
NoRecursion>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// Clean memory if needed.
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -947,7 +945,7 @@ void DecisionTree<FitnessFunction,
|
||||
|
||||
// Serialize the children first.
|
||||
size_t numChildren = children.size();
|
||||
ar & CreateNVP(numChildren, "numChildren");
|
||||
ar & BOOST_SERIALIZATION_NVP(numChildren);
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
children.resize(numChildren, NULL);
|
||||
@@ -959,13 +957,13 @@ void DecisionTree<FitnessFunction,
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << "child" << i;
|
||||
ar & CreateNVP(*children[i], name.str());
|
||||
ar & BOOST_SERIALIZATION_NVP(*children[i]);
|
||||
}
|
||||
|
||||
// Now serialize the rest of the object.
|
||||
ar & CreateNVP(splitDimension, "splitDimension");
|
||||
ar & CreateNVP(dimensionTypeOrMajorityClass, "dimensionTypeOrMajorityClass");
|
||||
ar & CreateNVP(classProbabilities, "classProbabilities");
|
||||
ar & BOOST_SERIALIZATION_NVP(splitDimension);
|
||||
ar & BOOST_SERIALIZATION_NVP(dimensionTypeOrMajorityClass);
|
||||
ar & BOOST_SERIALIZATION_NVP(classProbabilities);
|
||||
}
|
||||
|
||||
template<typename FitnessFunction,
|
||||
|
||||
@@ -102,9 +102,9 @@ class DecisionTreeModel
|
||||
|
||||
// Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(tree, "tree");
|
||||
ar & BOOST_SERIALIZATION_NVP(tree);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ class DTree
|
||||
* Serialize the density estimation tree.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
// Utility methods.
|
||||
|
||||
@@ -946,25 +946,23 @@ DTree<MatType, TagType>::ComputeVariableImportance(arma::vec& importances) const
|
||||
|
||||
template <typename MatType, typename TagType>
|
||||
template <typename Archive>
|
||||
void DTree<MatType, TagType>::Serialize(Archive& ar,
|
||||
void DTree<MatType, TagType>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(start, "start");
|
||||
ar & CreateNVP(end, "end");
|
||||
ar & CreateNVP(maxVals, "maxVals");
|
||||
ar & CreateNVP(minVals, "minVals");
|
||||
ar & CreateNVP(splitDim, "splitDim");
|
||||
ar & CreateNVP(splitValue, "splitValue");
|
||||
ar & CreateNVP(logNegError, "logNegError");
|
||||
ar & CreateNVP(subtreeLeavesLogNegError, "subtreeLeavesLogNegError");
|
||||
ar & CreateNVP(subtreeLeaves, "subtreeLeaves");
|
||||
ar & CreateNVP(root, "root");
|
||||
ar & CreateNVP(ratio, "ratio");
|
||||
ar & CreateNVP(logVolume, "logVolume");
|
||||
ar & CreateNVP(bucketTag, "bucketTag");
|
||||
ar & CreateNVP(alphaUpper, "alphaUpper");
|
||||
ar & BOOST_SERIALIZATION_NVP(start);
|
||||
ar & BOOST_SERIALIZATION_NVP(end);
|
||||
ar & BOOST_SERIALIZATION_NVP(maxVals);
|
||||
ar & BOOST_SERIALIZATION_NVP(minVals);
|
||||
ar & BOOST_SERIALIZATION_NVP(splitDim);
|
||||
ar & BOOST_SERIALIZATION_NVP(splitValue);
|
||||
ar & BOOST_SERIALIZATION_NVP(logNegError);
|
||||
ar & BOOST_SERIALIZATION_NVP(subtreeLeavesLogNegError);
|
||||
ar & BOOST_SERIALIZATION_NVP(subtreeLeaves);
|
||||
ar & BOOST_SERIALIZATION_NVP(root);
|
||||
ar & BOOST_SERIALIZATION_NVP(ratio);
|
||||
ar & BOOST_SERIALIZATION_NVP(logVolume);
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketTag);
|
||||
ar & BOOST_SERIALIZATION_NVP(alphaUpper);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -974,7 +972,7 @@ void DTree<MatType, TagType>::Serialize(Archive& ar,
|
||||
delete right;
|
||||
}
|
||||
|
||||
ar & CreateNVP(left, "left");
|
||||
ar & CreateNVP(right, "right");
|
||||
ar & BOOST_SERIALIZATION_NVP(left);
|
||||
ar & BOOST_SERIALIZATION_NVP(right);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ class FastMKS
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! The reference dataset. We never own this; only the tree or a higher level
|
||||
|
||||
@@ -509,15 +509,13 @@ template<typename KernelType,
|
||||
typename TreeStatType,
|
||||
typename TreeMatType> class TreeType>
|
||||
template<typename Archive>
|
||||
void FastMKS<KernelType, MatType, TreeType>::Serialize(
|
||||
void FastMKS<KernelType, MatType, TreeType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// Serialize preferences for search.
|
||||
ar & CreateNVP(naive, "naive");
|
||||
ar & CreateNVP(singleMode, "singleMode");
|
||||
ar & BOOST_SERIALIZATION_NVP(naive);
|
||||
ar & BOOST_SERIALIZATION_NVP(singleMode);
|
||||
|
||||
// If we are doing naive search, serialize the dataset. Otherwise we
|
||||
// serialize the tree.
|
||||
@@ -531,8 +529,8 @@ void FastMKS<KernelType, MatType, TreeType>::Serialize(
|
||||
setOwner = true;
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceSet, "referenceSet");
|
||||
ar & CreateNVP(metric, "metric");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(metric);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -545,7 +543,7 @@ void FastMKS<KernelType, MatType, TreeType>::Serialize(
|
||||
treeOwner = true;
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceTree, "referenceTree");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceTree);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
|
||||
@@ -126,7 +126,7 @@ class FastMKSModel
|
||||
* Serialize the model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! The type of kernel we are using.
|
||||
|
||||
@@ -126,11 +126,9 @@ void FastMKSModel::BuildModel(const arma::mat& referenceData,
|
||||
}
|
||||
|
||||
template<typename Archive>
|
||||
void FastMKSModel::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void FastMKSModel::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(kernelType, "kernelType");
|
||||
ar & BOOST_SERIALIZATION_NVP(kernelType);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -163,31 +161,31 @@ void FastMKSModel::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
switch (kernelType)
|
||||
{
|
||||
case LINEAR_KERNEL:
|
||||
ar & CreateNVP(linear, "linear_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(linear);
|
||||
break;
|
||||
|
||||
case POLYNOMIAL_KERNEL:
|
||||
ar & CreateNVP(polynomial, "polynomial_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(polynomial);
|
||||
break;
|
||||
|
||||
case COSINE_DISTANCE:
|
||||
ar & CreateNVP(cosine, "cosine_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(cosine);
|
||||
break;
|
||||
|
||||
case GAUSSIAN_KERNEL:
|
||||
ar & CreateNVP(gaussian, "gaussian_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(gaussian);
|
||||
break;
|
||||
|
||||
case EPANECHNIKOV_KERNEL:
|
||||
ar & CreateNVP(epan, "epan_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(epan);
|
||||
break;
|
||||
|
||||
case TRIANGULAR_KERNEL:
|
||||
ar & CreateNVP(triangular, "triangular_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(triangular);
|
||||
break;
|
||||
|
||||
case HYPTAN_KERNEL:
|
||||
ar & CreateNVP(hyptan, "hyptan_fastmks");
|
||||
ar & BOOST_SERIALIZATION_NVP(hyptan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ class FastMKSStat
|
||||
|
||||
//! Serialize the statistic.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(bound, "bound");
|
||||
ar & data::CreateNVP(selfKernel, "selfKernel");
|
||||
ar & BOOST_SERIALIZATION_NVP(bound);
|
||||
ar & BOOST_SERIALIZATION_NVP(selfKernel);
|
||||
|
||||
// Void out last kernel information on load.
|
||||
if (Archive::is_loading::value)
|
||||
|
||||
@@ -32,7 +32,7 @@ class DiagonalConstraint
|
||||
|
||||
//! Serialize the constraint (which holds nothing, so, nothing to do).
|
||||
template<typename Archive>
|
||||
static void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
static void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace gmm
|
||||
|
||||
@@ -78,11 +78,11 @@ class EigenvalueRatioConstraint
|
||||
|
||||
//! Serialize the constraint.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
// Strip the const for the sake of loading/saving. This is the only time it
|
||||
// is modified (other than the constructor).
|
||||
ar & data::CreateNVP(const_cast<arma::vec&>(ratios), "ratios");
|
||||
ar & BOOST_SERIALIZATION_NVP(const_cast<arma::vec&>(ratios));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -130,7 +130,7 @@ class EMFit
|
||||
|
||||
//! Serialize the fitter.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -316,16 +316,14 @@ double EMFit<InitialClusteringType, CovarianceConstraintPolicy>::LogLikelihood(
|
||||
|
||||
template<typename InitialClusteringType, typename CovarianceConstraintPolicy>
|
||||
template<typename Archive>
|
||||
void EMFit<InitialClusteringType, CovarianceConstraintPolicy>::Serialize(
|
||||
void EMFit<InitialClusteringType, CovarianceConstraintPolicy>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(maxIterations, "maxIterations");
|
||||
ar & CreateNVP(tolerance, "tolerance");
|
||||
ar & CreateNVP(clusterer, "clusterer");
|
||||
ar & CreateNVP(constraint, "constraint");
|
||||
ar & BOOST_SERIALIZATION_NVP(maxIterations);
|
||||
ar & BOOST_SERIALIZATION_NVP(tolerance);
|
||||
ar & BOOST_SERIALIZATION_NVP(clusterer);
|
||||
ar & BOOST_SERIALIZATION_NVP(constraint);
|
||||
}
|
||||
|
||||
// Armadillo uses uword internally as an OpenMP index type, which crashes Visual
|
||||
|
||||
@@ -265,7 +265,7 @@ class GMM
|
||||
* Serialize the GMM.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -191,27 +191,20 @@ double GMM::Train(const arma::mat& observations,
|
||||
* Serialize the object.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void GMM::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void GMM::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(gaussians, "gaussians");
|
||||
ar & CreateNVP(dimensionality, "dimensionality");
|
||||
ar & BOOST_SERIALIZATION_NVP(gaussians);
|
||||
ar & BOOST_SERIALIZATION_NVP(dimensionality);
|
||||
|
||||
// Load (or save) the gaussians. Not going to use the default std::vector
|
||||
// serialize here because it won't call out correctly to Serialize() for each
|
||||
// serialize here because it won't call out correctly to serialize() for each
|
||||
// Gaussian distribution.
|
||||
if (Archive::is_loading::value)
|
||||
dists.resize(gaussians);
|
||||
|
||||
for (size_t i = 0; i < gaussians; ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "dist" << i;
|
||||
ar & CreateNVP(dists[i], oss.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(dists);
|
||||
|
||||
ar & CreateNVP(weights, "weights");
|
||||
ar & BOOST_SERIALIZATION_NVP(weights);
|
||||
}
|
||||
|
||||
} // namespace gmm
|
||||
|
||||
@@ -30,7 +30,7 @@ class NoConstraint
|
||||
|
||||
//! Serialize the object (nothing to do).
|
||||
template<typename Archive>
|
||||
static void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
static void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace gmm
|
||||
|
||||
@@ -64,7 +64,7 @@ class PositiveDefiniteConstraint
|
||||
|
||||
//! Serialize the constraint (which stores nothing, so, nothing to do).
|
||||
template<typename Archive>
|
||||
static void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
static void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace gmm
|
||||
|
||||
@@ -326,7 +326,7 @@ class HMM
|
||||
* Serialize the object.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
protected:
|
||||
// Helper functions.
|
||||
|
||||
@@ -587,12 +587,12 @@ void HMM<Distribution>::Backward(const arma::mat& dataSeq,
|
||||
//! Serialize the HMM.
|
||||
template<typename Distribution>
|
||||
template<typename Archive>
|
||||
void HMM<Distribution>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void HMM<Distribution>::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(dimensionality, "dimensionality");
|
||||
ar & data::CreateNVP(tolerance, "tolerance");
|
||||
ar & data::CreateNVP(transition, "transition");
|
||||
ar & data::CreateNVP(initial, "initial");
|
||||
ar & BOOST_SERIALIZATION_NVP(dimensionality);
|
||||
ar & BOOST_SERIALIZATION_NVP(tolerance);
|
||||
ar & BOOST_SERIALIZATION_NVP(transition);
|
||||
ar & BOOST_SERIALIZATION_NVP(initial);
|
||||
|
||||
// Now serialize each emission. If we are loading, we must resize the vector
|
||||
// of emissions correctly.
|
||||
@@ -600,12 +600,7 @@ void HMM<Distribution>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
emission.resize(transition.n_rows);
|
||||
|
||||
// Load the emissions; generate the correct name for each one.
|
||||
for (size_t i = 0; i < emission.size(); ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "emission" << i;
|
||||
ar & data::CreateNVP(emission[i], oss.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(emission);
|
||||
}
|
||||
|
||||
} // namespace hmm
|
||||
|
||||
@@ -141,9 +141,9 @@ class HMMModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(type, "type");
|
||||
ar & BOOST_SERIALIZATION_NVP(type);
|
||||
|
||||
// If necessary, clean memory.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -158,11 +158,11 @@ class HMMModel
|
||||
}
|
||||
|
||||
if (type == HMMType::DiscreteHMM)
|
||||
ar & data::CreateNVP(discreteHMM, "discreteHMM");
|
||||
ar & BOOST_SERIALIZATION_NVP(discreteHMM);
|
||||
else if (type == HMMType::GaussianHMM)
|
||||
ar & data::CreateNVP(gaussianHMM, "gaussianHMM");
|
||||
ar & BOOST_SERIALIZATION_NVP(gaussianHMM);
|
||||
else if (type == HMMType::GaussianMixtureModelHMM)
|
||||
ar & data::CreateNVP(gmmHMM, "gmmHMM");
|
||||
ar & BOOST_SERIALIZATION_NVP(gmmHMM);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ void LoadHMMAndPerformActionHelper(const std::string& modelFile,
|
||||
|
||||
// Read in the unsigned integer that denotes the type of the model.
|
||||
char type;
|
||||
ar >> data::CreateNVP(type, "hmm_type");
|
||||
ar >> BOOST_SERIALIZATION_NVP(type);
|
||||
|
||||
using namespace mlpack::distribution;
|
||||
|
||||
@@ -101,7 +101,7 @@ void DeserializeHMMAndPerformAction(ArchiveType& ar, ExtraInfoType* x)
|
||||
{
|
||||
// Extract the HMM and perform the action.
|
||||
HMMType hmm;
|
||||
ar >> data::CreateNVP(hmm, "hmm");
|
||||
ar >> BOOST_SERIALIZATION_NVP(hmm);
|
||||
ActionType::Apply(hmm, x);
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ void SaveHMMHelper(HMMType& hmm, const std::string& modelFile)
|
||||
if (type == char(-1))
|
||||
Log::Fatal << "Unknown HMM type given to SaveHMM()!" << std::endl;
|
||||
|
||||
ar << data::CreateNVP(type, "hmm_type");
|
||||
ar << data::CreateNVP(hmm, "hmm");
|
||||
ar << BOOST_SERIALIZATION_NVP(type);
|
||||
ar << BOOST_SERIALIZATION_NVP(hmm);
|
||||
}
|
||||
|
||||
// Utility functions to turn a type into something we can store.
|
||||
|
||||
@@ -108,7 +108,7 @@ class BinaryNumericSplit
|
||||
|
||||
//! Serialize the object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! The elements seen so far, in sorted order.
|
||||
|
||||
@@ -170,13 +170,13 @@ double BinaryNumericSplit<FitnessFunction, ObservationType>::
|
||||
|
||||
template<typename FitnessFunction, typename ObservationType>
|
||||
template<typename Archive>
|
||||
void BinaryNumericSplit<FitnessFunction, ObservationType>::Serialize(
|
||||
void BinaryNumericSplit<FitnessFunction, ObservationType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
// Serialize.
|
||||
ar & data::CreateNVP(sortedElements, "sortedElements");
|
||||
ar & data::CreateNVP(classCounts, "classCounts");
|
||||
ar & BOOST_SERIALIZATION_NVP(sortedElements);
|
||||
ar & BOOST_SERIALIZATION_NVP(classCounts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class BinaryNumericSplitInfo
|
||||
|
||||
//! Serialize the split (save/load the split points).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(splitPoint, "splitPoint");
|
||||
ar & BOOST_SERIALIZATION_NVP(splitPoint);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,7 @@ class CategoricalSplitInfo
|
||||
|
||||
//! Serialize the object. (Nothing needs to be saved.)
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace tree
|
||||
|
||||
@@ -108,9 +108,9 @@ class HoeffdingCategoricalSplit
|
||||
|
||||
//! Serialize the categorical split.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(sufficientStatistics, "sufficientStatistics");
|
||||
ar & BOOST_SERIALIZATION_NVP(sufficientStatistics);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -121,7 +121,7 @@ class HoeffdingNumericSplit
|
||||
|
||||
//! Serialize the object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Before binning, this holds the points we have seen so far.
|
||||
|
||||
@@ -188,21 +188,19 @@ double HoeffdingNumericSplit<FitnessFunction, ObservationType>::
|
||||
|
||||
template<typename FitnessFunction, typename ObservationType>
|
||||
template<typename Archive>
|
||||
void HoeffdingNumericSplit<FitnessFunction, ObservationType>::Serialize(
|
||||
void HoeffdingNumericSplit<FitnessFunction, ObservationType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(samplesSeen, "samplesSeen");
|
||||
ar & CreateNVP(observationsBeforeBinning, "observationsBeforeBinning");
|
||||
ar & CreateNVP(bins, "bins");
|
||||
ar & BOOST_SERIALIZATION_NVP(samplesSeen);
|
||||
ar & BOOST_SERIALIZATION_NVP(observationsBeforeBinning);
|
||||
ar & BOOST_SERIALIZATION_NVP(bins);
|
||||
|
||||
if (samplesSeen >= observationsBeforeBinning)
|
||||
{
|
||||
// The binning has happened, so we only need to save the resulting bins.
|
||||
ar & CreateNVP(splitPoints, "splitPoints");
|
||||
ar & CreateNVP(sufficientStatistics, "sufficientStatistics");
|
||||
ar & BOOST_SERIALIZATION_NVP(splitPoints);
|
||||
ar & BOOST_SERIALIZATION_NVP(sufficientStatistics);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -225,18 +223,9 @@ void HoeffdingNumericSplit<FitnessFunction, ObservationType>::Serialize(
|
||||
size_t numClasses;
|
||||
if (Archive::is_saving::value)
|
||||
numClasses = sufficientStatistics.n_rows;
|
||||
ar & data::CreateNVP(numClasses, "numClasses");
|
||||
|
||||
for (size_t i = 0; i < samplesSeen; ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "obs" << i;
|
||||
ar & CreateNVP(observations[i], oss.str());
|
||||
|
||||
std::ostringstream oss2;
|
||||
oss2 << "label" << i;
|
||||
ar & CreateNVP(labels[i], oss2.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(numClasses);
|
||||
ar & BOOST_SERIALIZATION_NVP(observations);
|
||||
ar & BOOST_SERIALIZATION_NVP(labels);
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
|
||||
@@ -289,7 +289,7 @@ class HoeffdingTree
|
||||
|
||||
//! Serialize the split.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
// We need to keep some information for before we have split.
|
||||
|
||||
@@ -692,23 +692,21 @@ void HoeffdingTree<
|
||||
FitnessFunction,
|
||||
NumericSplitType,
|
||||
CategoricalSplitType
|
||||
>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
>::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(splitDimension, "splitDimension");
|
||||
ar & BOOST_SERIALIZATION_NVP(splitDimension);
|
||||
|
||||
// Clear memory for the mappings if necessary.
|
||||
if (Archive::is_loading::value && ownsMappings && dimensionMappings)
|
||||
delete dimensionMappings;
|
||||
|
||||
ar & CreateNVP(dimensionMappings, "dimensionMappings");
|
||||
ar & BOOST_SERIALIZATION_NVP(dimensionMappings);
|
||||
|
||||
// Special handling for const object.
|
||||
data::DatasetInfo* d = NULL;
|
||||
if (Archive::is_saving::value)
|
||||
d = const_cast<data::DatasetInfo*>(datasetInfo);
|
||||
ar & CreateNVP(d, "datasetInfo");
|
||||
ar & BOOST_SERIALIZATION_NVP(d);
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
if (datasetInfo && ownsInfo)
|
||||
@@ -724,18 +722,18 @@ void HoeffdingTree<
|
||||
children.clear();
|
||||
}
|
||||
|
||||
ar & CreateNVP(majorityClass, "majorityClass");
|
||||
ar & CreateNVP(majorityProbability, "majorityProbability");
|
||||
ar & BOOST_SERIALIZATION_NVP(majorityClass);
|
||||
ar & BOOST_SERIALIZATION_NVP(majorityProbability);
|
||||
|
||||
// Depending on whether or not we have split yet, we may need to save
|
||||
// different things.
|
||||
if (splitDimension == size_t(-1))
|
||||
{
|
||||
// We have not yet split. So we have to serialize the splits.
|
||||
ar & CreateNVP(numSamples, "numSamples");
|
||||
ar & CreateNVP(numClasses, "numClasses");
|
||||
ar & CreateNVP(maxSamples, "maxSamples");
|
||||
ar & CreateNVP(successProbability, "successProbability");
|
||||
ar & BOOST_SERIALIZATION_NVP(numSamples);
|
||||
ar & BOOST_SERIALIZATION_NVP(numClasses);
|
||||
ar & BOOST_SERIALIZATION_NVP(maxSamples);
|
||||
ar & BOOST_SERIALIZATION_NVP(successProbability);
|
||||
|
||||
// Serialize the splits, but not if we haven't seen any samples yet (in
|
||||
// which case we can just reinitialize).
|
||||
@@ -766,34 +764,24 @@ void HoeffdingTree<
|
||||
return;
|
||||
|
||||
// Serialize numeric splits.
|
||||
for (size_t i = 0; i < numericSplits.size(); ++i)
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << "numericSplit" << i;
|
||||
ar & CreateNVP(numericSplits[i], name.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(numericSplits);
|
||||
|
||||
// Serialize categorical splits.
|
||||
for (size_t i = 0; i < categoricalSplits.size(); ++i)
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << "categoricalSplit" << i;
|
||||
ar & CreateNVP(categoricalSplits[i], name.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(categoricalSplits);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have split, so we only need to save the split and the children.
|
||||
if (datasetInfo->Type(splitDimension) == data::Datatype::categorical)
|
||||
ar & CreateNVP(categoricalSplit, "categoricalSplit");
|
||||
ar & BOOST_SERIALIZATION_NVP(categoricalSplit);
|
||||
else
|
||||
ar & CreateNVP(numericSplit, "numericSplit");
|
||||
ar & BOOST_SERIALIZATION_NVP(numericSplit);
|
||||
|
||||
// Serialize the children, because we have split.
|
||||
size_t numChildren;
|
||||
if (Archive::is_saving::value)
|
||||
numChildren = children.size();
|
||||
ar & CreateNVP(numChildren, "numChildren");
|
||||
ar & BOOST_SERIALIZATION_NVP(numChildren);
|
||||
if (Archive::is_loading::value) // If needed, allocate space.
|
||||
{
|
||||
children.resize(numChildren, NULL);
|
||||
@@ -805,7 +793,7 @@ void HoeffdingTree<
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << "child" << i;
|
||||
ar & data::CreateNVP(*children[i], name.str());
|
||||
ar & BOOST_SERIALIZATION_NVP(*children[i]);
|
||||
|
||||
// The child doesn't actually own its own DatasetInfo. We do. The same
|
||||
// applies for the dimension mappings.
|
||||
|
||||
@@ -161,10 +161,8 @@ class HoeffdingTreeModel
|
||||
* Serialize the model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(type, "type");
|
||||
|
||||
// Clear memory if needed.
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -186,28 +184,28 @@ class HoeffdingTreeModel
|
||||
// Create fake tree to load into if needed.
|
||||
if (Archive::is_loading::value)
|
||||
giniHoeffdingTree = new GiniHoeffdingTreeType(info, 1, 1);
|
||||
ar & data::CreateNVP(*giniHoeffdingTree, "giniHoeffdingTree");
|
||||
ar & BOOST_SERIALIZATION_NVP(*giniHoeffdingTree);
|
||||
}
|
||||
else if (type == GINI_BINARY)
|
||||
{
|
||||
// Create fake tree to load into if needed.
|
||||
if (Archive::is_loading::value)
|
||||
giniBinaryTree = new GiniBinaryTreeType(info, 1, 1);
|
||||
ar & data::CreateNVP(*giniBinaryTree, "giniBinaryTree");
|
||||
ar & BOOST_SERIALIZATION_NVP(*giniBinaryTree);
|
||||
}
|
||||
else if (type == INFO_HOEFFDING)
|
||||
{
|
||||
// Create fake tree to load into if needed.
|
||||
if (Archive::is_loading::value)
|
||||
infoHoeffdingTree = new InfoHoeffdingTreeType(info, 1, 1);
|
||||
ar & data::CreateNVP(*infoHoeffdingTree, "infoHoeffdingTree");
|
||||
ar & BOOST_SERIALIZATION_NVP(*infoHoeffdingTree);
|
||||
}
|
||||
else if (type == INFO_BINARY)
|
||||
{
|
||||
// Create fake tree to load into if needed.
|
||||
if (Archive::is_loading::value)
|
||||
infoBinaryTree = new InfoBinaryTreeType(info, 1, 1);
|
||||
ar & data::CreateNVP(*infoBinaryTree, "infoBinaryTree");
|
||||
ar & BOOST_SERIALIZATION_NVP(*infoBinaryTree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ class NumericSplitInfo
|
||||
|
||||
//! Serialize the split (save/load the split points).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(splitPoints, "splitPoints");
|
||||
ar & BOOST_SERIALIZATION_NVP(splitPoints);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -62,7 +62,7 @@ class AllowEmptyClusters
|
||||
|
||||
//! Serialize the empty cluster policy (nothing to do).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace kmeans
|
||||
|
||||
@@ -62,7 +62,7 @@ class KillEmptyClusters
|
||||
|
||||
//! Serialize the empty cluster policy (nothing to do).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace kmeans
|
||||
|
||||
@@ -178,7 +178,7 @@ class KMeans
|
||||
|
||||
//! Serialize the k-means object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
private:
|
||||
//! Maximum number of iterations before giving up.
|
||||
|
||||
@@ -347,12 +347,12 @@ void KMeans<MetricType,
|
||||
InitialPartitionPolicy,
|
||||
EmptyClusterPolicy,
|
||||
LloydStepType,
|
||||
MatType>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
MatType>::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(maxIterations, "max_iterations");
|
||||
ar & data::CreateNVP(metric, "metric");
|
||||
ar & data::CreateNVP(partitioner, "partitioner");
|
||||
ar & data::CreateNVP(emptyClusterAction, "emptyClusterAction");
|
||||
ar & BOOST_SERIALIZATION_NVP(maxIterations);
|
||||
ar & BOOST_SERIALIZATION_NVP(metric);
|
||||
ar & BOOST_SERIALIZATION_NVP(partitioner);
|
||||
ar & BOOST_SERIALIZATION_NVP(emptyClusterAction);
|
||||
}
|
||||
|
||||
} // namespace kmeans
|
||||
|
||||
@@ -56,7 +56,7 @@ class MaxVarianceNewCluster
|
||||
|
||||
//! Serialize the object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
private:
|
||||
//! Index of iteration for which variance is cached.
|
||||
|
||||
@@ -100,7 +100,7 @@ size_t MaxVarianceNewCluster::EmptyCluster(const MatType& data,
|
||||
|
||||
//! Serialize the object.
|
||||
template<typename Archive>
|
||||
void MaxVarianceNewCluster::Serialize(Archive& /* ar */,
|
||||
void MaxVarianceNewCluster::serialize(Archive& /* ar */,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
// Serialization is useless here, because the only thing we store is
|
||||
|
||||
@@ -52,7 +52,7 @@ class RandomPartition
|
||||
|
||||
//! Serialize the partitioner (nothing to do).
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
void serialize(Archive& /* ar */, const unsigned int /* version */) { }
|
||||
};
|
||||
|
||||
} // namespace kmeans
|
||||
|
||||
@@ -89,10 +89,10 @@ class RefinedStart
|
||||
|
||||
//! Serialize the object.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(samplings, "samplings");
|
||||
ar & data::CreateNVP(percentage, "percentage");
|
||||
ar & BOOST_SERIALIZATION_NVP(samplings);
|
||||
ar & BOOST_SERIALIZATION_NVP(percentage);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -337,7 +337,7 @@ class LARS
|
||||
* Serialize the LARS model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Gram matrix.
|
||||
@@ -428,7 +428,7 @@ class LARS
|
||||
} // namespace regression
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation of Serialize().
|
||||
// Include implementation of serialize().
|
||||
#include "lars_impl.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,34 +22,32 @@ namespace regression {
|
||||
* Serialize the LARS model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void LARS::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void LARS::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// If we're loading, we have to use the internal storage.
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
matGram = &matGramInternal;
|
||||
ar & CreateNVP(matGramInternal, "matGramInternal");
|
||||
ar & BOOST_SERIALIZATION_NVP(matGramInternal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ar & CreateNVP(const_cast<arma::mat&>(*matGram), "matGramInternal");
|
||||
ar & BOOST_SERIALIZATION_NVP(const_cast<arma::mat&>(*matGram));
|
||||
}
|
||||
|
||||
ar & CreateNVP(matUtriCholFactor, "matUtriCholFactor");
|
||||
ar & CreateNVP(useCholesky, "useCholesky");
|
||||
ar & CreateNVP(lasso, "lasso");
|
||||
ar & CreateNVP(lambda1, "lambda1");
|
||||
ar & CreateNVP(elasticNet, "elasticNet");
|
||||
ar & CreateNVP(lambda2, "lambda2");
|
||||
ar & CreateNVP(tolerance, "tolerance");
|
||||
ar & CreateNVP(betaPath, "betaPath");
|
||||
ar & CreateNVP(lambdaPath, "lambdaPath");
|
||||
ar & CreateNVP(activeSet, "activeSet");
|
||||
ar & CreateNVP(isActive, "isActive");
|
||||
ar & CreateNVP(ignoreSet, "ignoreSet");
|
||||
ar & CreateNVP(isIgnored, "isIgnored");
|
||||
ar & BOOST_SERIALIZATION_NVP(matUtriCholFactor);
|
||||
ar & BOOST_SERIALIZATION_NVP(useCholesky);
|
||||
ar & BOOST_SERIALIZATION_NVP(lasso);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambda1);
|
||||
ar & BOOST_SERIALIZATION_NVP(elasticNet);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambda2);
|
||||
ar & BOOST_SERIALIZATION_NVP(tolerance);
|
||||
ar & BOOST_SERIALIZATION_NVP(betaPath);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambdaPath);
|
||||
ar & BOOST_SERIALIZATION_NVP(activeSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(isActive);
|
||||
ar & BOOST_SERIALIZATION_NVP(ignoreSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(isIgnored);
|
||||
}
|
||||
|
||||
} // namespace regression
|
||||
|
||||
@@ -199,11 +199,11 @@ class LinearRegression
|
||||
* Serialize the model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(parameters, "parameters");
|
||||
ar & data::CreateNVP(lambda, "lambda");
|
||||
ar & data::CreateNVP(intercept, "intercept");
|
||||
ar & BOOST_SERIALIZATION_NVP(parameters);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambda);
|
||||
ar & BOOST_SERIALIZATION_NVP(intercept);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -197,7 +197,7 @@ class LocalCoordinateCoding
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Number of atoms in dictionary.
|
||||
|
||||
@@ -106,14 +106,14 @@ void LocalCoordinateCoding::Train(
|
||||
}
|
||||
|
||||
template<typename Archive>
|
||||
void LocalCoordinateCoding::Serialize(Archive& ar,
|
||||
void LocalCoordinateCoding::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(atoms, "atoms");
|
||||
ar & data::CreateNVP(dictionary, "dictionary");
|
||||
ar & data::CreateNVP(lambda, "lambda");
|
||||
ar & data::CreateNVP(maxIterations, "maxIterations");
|
||||
ar & data::CreateNVP(tolerance, "tolerance");
|
||||
ar & BOOST_SERIALIZATION_NVP(atoms);
|
||||
ar & BOOST_SERIALIZATION_NVP(dictionary);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambda);
|
||||
ar & BOOST_SERIALIZATION_NVP(maxIterations);
|
||||
ar & BOOST_SERIALIZATION_NVP(tolerance);
|
||||
}
|
||||
|
||||
} // namespace lcc
|
||||
|
||||
@@ -248,7 +248,7 @@ class LogisticRegression
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Vector of trained parameters (size: dimensionality plus one).
|
||||
|
||||
@@ -175,12 +175,12 @@ double LogisticRegression<MatType>::ComputeAccuracy(
|
||||
|
||||
template<typename MatType>
|
||||
template<typename Archive>
|
||||
void LogisticRegression<MatType>::Serialize(
|
||||
void LogisticRegression<MatType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(parameters, "parameters");
|
||||
ar & data::CreateNVP(lambda, "lambda");
|
||||
ar & BOOST_SERIALIZATION_NVP(parameters);
|
||||
ar & BOOST_SERIALIZATION_NVP(lambda);
|
||||
}
|
||||
|
||||
} // namespace regression
|
||||
|
||||
@@ -259,7 +259,7 @@ class LSHSearch
|
||||
* @param ar Archive to serialize to.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
//! Return the number of distance evaluations performed.
|
||||
size_t DistanceEvaluations() const { return distanceEvaluations; }
|
||||
|
||||
@@ -1062,11 +1062,9 @@ double LSHSearch<SortPolicy>::ComputeRecall(
|
||||
|
||||
template<typename SortPolicy>
|
||||
template<typename Archive>
|
||||
void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
void LSHSearch<SortPolicy>::serialize(Archive& ar,
|
||||
const unsigned int version)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// If we are loading, we are going to own the reference set.
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
@@ -1074,10 +1072,10 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
delete referenceSet;
|
||||
ownsSet = true;
|
||||
}
|
||||
ar & CreateNVP(referenceSet, "referenceSet");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceSet);
|
||||
|
||||
ar & CreateNVP(numProj, "numProj");
|
||||
ar & CreateNVP(numTables, "numTables");
|
||||
ar & BOOST_SERIALIZATION_NVP(numProj);
|
||||
ar & BOOST_SERIALIZATION_NVP(numTables);
|
||||
|
||||
// Delete existing projections, if necessary.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -1088,7 +1086,7 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
if (version == 0)
|
||||
{
|
||||
std::vector<arma::mat> tmpProj;
|
||||
ar & CreateNVP(tmpProj, "projections");
|
||||
ar & BOOST_SERIALIZATION_NVP(tmpProj);
|
||||
|
||||
projections.set_size(tmpProj[0].n_rows, tmpProj[0].n_cols, tmpProj.size());
|
||||
for (size_t i = 0; i < tmpProj.size(); ++i)
|
||||
@@ -1096,14 +1094,14 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
}
|
||||
else
|
||||
{
|
||||
ar & CreateNVP(projections, "projections");
|
||||
ar & BOOST_SERIALIZATION_NVP(projections);
|
||||
}
|
||||
|
||||
ar & CreateNVP(offsets, "offsets");
|
||||
ar & CreateNVP(hashWidth, "hashWidth");
|
||||
ar & CreateNVP(secondHashSize, "secondHashSize");
|
||||
ar & CreateNVP(secondHashWeights, "secondHashWeights");
|
||||
ar & CreateNVP(bucketSize, "bucketSize");
|
||||
ar & BOOST_SERIALIZATION_NVP(offsets);
|
||||
ar & BOOST_SERIALIZATION_NVP(hashWidth);
|
||||
ar & BOOST_SERIALIZATION_NVP(secondHashSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(secondHashWeights);
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketSize);
|
||||
// needs specific handling for new version
|
||||
|
||||
// Backward compatibility: in older versions of LSHSearch, the secondHashTable
|
||||
@@ -1112,7 +1110,7 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
if (version == 0)
|
||||
{
|
||||
arma::Mat<size_t> tmpSecondHashTable;
|
||||
ar & CreateNVP(tmpSecondHashTable, "secondHashTable");
|
||||
ar & BOOST_SERIALIZATION_NVP(tmpSecondHashTable);
|
||||
|
||||
// The old secondHashTable was stored in row-major format, so we transpose
|
||||
// it.
|
||||
@@ -1140,7 +1138,7 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
size_t tables;
|
||||
if (Archive::is_saving::value)
|
||||
tables = secondHashTable.size();
|
||||
ar & CreateNVP(tables, "numSecondHashTables");
|
||||
ar & BOOST_SERIALIZATION_NVP(tables);
|
||||
|
||||
// Set size of second hash table if needed.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -1149,12 +1147,7 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
secondHashTable.resize(tables);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < secondHashTable.size(); ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "secondHashTable" << i;
|
||||
ar & CreateNVP(secondHashTable[i], oss.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(secondHashTable);
|
||||
}
|
||||
|
||||
// Backward compatibility: old versions of LSHSearch held bucketContentSize
|
||||
@@ -1166,8 +1159,8 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
// it. But we can't do that until we have bucketRowInHashTable, so we also
|
||||
// have to load that.
|
||||
arma::Col<size_t> tmpBucketContentSize;
|
||||
ar & CreateNVP(tmpBucketContentSize, "bucketContentSize");
|
||||
ar & CreateNVP(bucketRowInHashTable, "bucketRowInHashTable");
|
||||
ar & BOOST_SERIALIZATION_NVP(tmpBucketContentSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketRowInHashTable);
|
||||
|
||||
// Compress into a smaller vector by just dropping all of the zeros.
|
||||
bucketContentSize.set_size(secondHashTable.size());
|
||||
@@ -1177,11 +1170,11 @@ void LSHSearch<SortPolicy>::Serialize(Archive& ar,
|
||||
}
|
||||
else
|
||||
{
|
||||
ar & CreateNVP(bucketContentSize, "bucketContentSize");
|
||||
ar & CreateNVP(bucketRowInHashTable, "bucketRowInHashTable");
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketContentSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(bucketRowInHashTable);
|
||||
}
|
||||
|
||||
ar & CreateNVP(distanceEvaluations, "distanceEvaluations");
|
||||
ar & BOOST_SERIALIZATION_NVP(distanceEvaluations);
|
||||
}
|
||||
|
||||
} // namespace neighbor
|
||||
|
||||
@@ -213,7 +213,7 @@ class NaiveBayesClassifier
|
||||
|
||||
//! Serialize the classifier.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Sample mean for each class.
|
||||
|
||||
@@ -339,13 +339,13 @@ void NaiveBayesClassifier<ModelMatType>::Classify(
|
||||
|
||||
template<typename ModelMatType>
|
||||
template<typename Archive>
|
||||
void NaiveBayesClassifier<ModelMatType>::Serialize(
|
||||
void NaiveBayesClassifier<ModelMatType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(means, "means");
|
||||
ar & data::CreateNVP(variances, "variances");
|
||||
ar & data::CreateNVP(probabilities, "probabilities");
|
||||
ar & BOOST_SERIALIZATION_NVP(means);
|
||||
ar & BOOST_SERIALIZATION_NVP(variances);
|
||||
ar & BOOST_SERIALIZATION_NVP(probabilities);
|
||||
}
|
||||
|
||||
} // namespace naive_bayes
|
||||
|
||||
@@ -77,10 +77,10 @@ struct NBCModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(nbc, "nbc");
|
||||
ar & data::CreateNVP(mappings, "mappings");
|
||||
ar & BOOST_SERIALIZATION_NVP(nbc);
|
||||
ar & BOOST_SERIALIZATION_NVP(mappings);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ class NeighborSearch
|
||||
|
||||
//! Serialize the NeighborSearch model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
//! Permutations of reference points during tree building.
|
||||
|
||||
@@ -1082,15 +1082,13 @@ template<typename SortPolicy,
|
||||
template<typename> class SingleTreeTraversalType>
|
||||
template<typename Archive>
|
||||
void NeighborSearch<SortPolicy, MetricType, MatType, TreeType,
|
||||
DualTreeTraversalType, SingleTreeTraversalType>::Serialize(
|
||||
DualTreeTraversalType, SingleTreeTraversalType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// Serialize preferences for search.
|
||||
ar & CreateNVP(searchMode, "searchMode");
|
||||
ar & CreateNVP(treeNeedsReset, "treeNeedsReset");
|
||||
ar & BOOST_SERIALIZATION_NVP(searchMode);
|
||||
ar & BOOST_SERIALIZATION_NVP(treeNeedsReset);
|
||||
|
||||
// If we are doing naive search, we serialize the dataset. Otherwise we
|
||||
// serialize the tree.
|
||||
@@ -1105,8 +1103,8 @@ DualTreeTraversalType, SingleTreeTraversalType>::Serialize(
|
||||
setOwner = true; // We will own the reference set when we load it.
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceSet, "referenceSet");
|
||||
ar & CreateNVP(metric, "metric");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(metric);
|
||||
|
||||
// If we are loading, set the tree to NULL and clean up memory if necessary.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -1131,8 +1129,8 @@ DualTreeTraversalType, SingleTreeTraversalType>::Serialize(
|
||||
treeOwner = true;
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceTree, "referenceTree");
|
||||
ar & CreateNVP(oldFromNewReferences, "oldFromNewReferences");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceTree);
|
||||
ar & BOOST_SERIALIZATION_NVP(oldFromNewReferences);
|
||||
|
||||
// If we are loading, set the dataset accordingly and clean up memory if
|
||||
// necessary.
|
||||
|
||||
@@ -92,14 +92,12 @@ class NeighborSearchStat
|
||||
|
||||
//! Serialize the statistic to/from an archive.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(firstBound, "firstBound");
|
||||
ar & CreateNVP(secondBound, "secondBound");
|
||||
ar & CreateNVP(auxBound, "auxBound");
|
||||
ar & CreateNVP(lastDistance, "lastDistance");
|
||||
ar & BOOST_SERIALIZATION_NVP(firstBound);
|
||||
ar & BOOST_SERIALIZATION_NVP(secondBound);
|
||||
ar & BOOST_SERIALIZATION_NVP(auxBound);
|
||||
ar & BOOST_SERIALIZATION_NVP(lastDistance);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ class NSModel
|
||||
|
||||
//! Serialize the neighbor search model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Expose the dataset.
|
||||
const arma::mat& Dataset() const;
|
||||
|
||||
@@ -377,32 +377,32 @@ void serialize(
|
||||
SingleTreeTraversalType>& ns,
|
||||
const unsigned int version)
|
||||
{
|
||||
ns.Serialize(ar, version);
|
||||
ns.serialize(ar, version);
|
||||
}
|
||||
|
||||
//! Serialize the kNN model.
|
||||
template<typename SortPolicy>
|
||||
template<typename Archive>
|
||||
void NSModel<SortPolicy>::Serialize(Archive& ar, const unsigned int version)
|
||||
void NSModel<SortPolicy>::serialize(Archive& ar, const unsigned int version)
|
||||
{
|
||||
ar & data::CreateNVP(treeType, "treeType");
|
||||
ar & BOOST_SERIALIZATION_NVP(treeType);
|
||||
// Backward compatibility: older versions of NSModel didn't include these
|
||||
// parameters.
|
||||
if (version > 0)
|
||||
{
|
||||
ar & data::CreateNVP(leafSize, "leafSize");
|
||||
ar & data::CreateNVP(tau, "tau");
|
||||
ar & data::CreateNVP(rho, "rho");
|
||||
ar & BOOST_SERIALIZATION_NVP(leafSize);
|
||||
ar & BOOST_SERIALIZATION_NVP(tau);
|
||||
ar & BOOST_SERIALIZATION_NVP(rho);
|
||||
}
|
||||
ar & data::CreateNVP(randomBasis, "randomBasis");
|
||||
ar & data::CreateNVP(q, "q");
|
||||
ar & BOOST_SERIALIZATION_NVP(randomBasis);
|
||||
ar & BOOST_SERIALIZATION_NVP(q);
|
||||
|
||||
// This should never happen, but just in case, be clean with memory.
|
||||
if (Archive::is_loading::value)
|
||||
boost::apply_visitor(DeleteVisitor(), nSearch);
|
||||
|
||||
const std::string& name = NSModelName<SortPolicy>::Name();
|
||||
ar & data::CreateNVP(nSearch, name);
|
||||
ar & BOOST_SERIALIZATION_NVP(nSearch);
|
||||
}
|
||||
|
||||
//! Expose the dataset.
|
||||
|
||||
@@ -120,7 +120,7 @@ class Perceptron
|
||||
* Serialize the perceptron.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Get the maximum number of iterations.
|
||||
size_t MaxIterations() const { return maxIterations; }
|
||||
|
||||
@@ -197,15 +197,15 @@ template<typename LearnPolicy,
|
||||
typename WeightInitializationPolicy,
|
||||
typename MatType>
|
||||
template<typename Archive>
|
||||
void Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Serialize(
|
||||
void Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
// We just need to serialize the maximum number of iterations, the weights,
|
||||
// and the biases.
|
||||
ar & data::CreateNVP(maxIterations, "maxIterations");
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & data::CreateNVP(biases, "biases");
|
||||
ar & BOOST_SERIALIZATION_NVP(maxIterations);
|
||||
ar & BOOST_SERIALIZATION_NVP(weights);
|
||||
ar & BOOST_SERIALIZATION_NVP(biases);
|
||||
}
|
||||
|
||||
} // namespace perceptron
|
||||
|
||||
@@ -93,10 +93,10 @@ class PerceptronModel
|
||||
const Col<size_t>& Map() const { return map; }
|
||||
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(p, "perceptron");
|
||||
ar & data::CreateNVP(map, "mappings");
|
||||
ar & BOOST_SERIALIZATION_NVP(p);
|
||||
ar & BOOST_SERIALIZATION_NVP(map);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ class RandomForest
|
||||
* Serialize the random forest.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -385,7 +385,7 @@ void RandomForest<
|
||||
NumericSplitType,
|
||||
CategoricalSplitType,
|
||||
ElemType
|
||||
>::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
>::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
size_t numTrees;
|
||||
if (Archive::is_loading::value)
|
||||
@@ -393,18 +393,13 @@ void RandomForest<
|
||||
else
|
||||
numTrees = trees.size();
|
||||
|
||||
ar & data::CreateNVP(numTrees, "numTrees");
|
||||
ar & BOOST_SERIALIZATION_NVP(numTrees);
|
||||
|
||||
// Allocate space if needed.
|
||||
if (Archive::is_loading::value)
|
||||
trees.resize(numTrees);
|
||||
|
||||
for (size_t i = 0; i < numTrees; ++i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "tree" << i;
|
||||
ar & data::CreateNVP(trees[i], oss.str());
|
||||
}
|
||||
ar & BOOST_SERIALIZATION_NVP(trees);
|
||||
}
|
||||
|
||||
template<
|
||||
|
||||
@@ -56,9 +56,9 @@ class RandomForestModel
|
||||
|
||||
// Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(rf, "random_forest");
|
||||
ar & BOOST_SERIALIZATION_NVP(rf);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ class RangeSearch
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int version);
|
||||
void serialize(Archive& ar, const unsigned int version);
|
||||
|
||||
//! Return the reference set.
|
||||
const MatType& ReferenceSet() const { return *referenceSet; }
|
||||
|
||||
@@ -738,15 +738,13 @@ template<typename MetricType,
|
||||
typename TreeStatType,
|
||||
typename TreeMatType> class TreeType>
|
||||
template<typename Archive>
|
||||
void RangeSearch<MetricType, MatType, TreeType>::Serialize(
|
||||
void RangeSearch<MetricType, MatType, TreeType>::serialize(
|
||||
Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
// Serialize preferences for search.
|
||||
ar & CreateNVP(naive, "naive");
|
||||
ar & CreateNVP(singleMode, "singleMode");
|
||||
ar & BOOST_SERIALIZATION_NVP(naive);
|
||||
ar & BOOST_SERIALIZATION_NVP(singleMode);
|
||||
|
||||
// Reset base cases and scores if we are loading.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -767,8 +765,8 @@ void RangeSearch<MetricType, MatType, TreeType>::Serialize(
|
||||
setOwner = true;
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceSet, "referenceSet");
|
||||
ar & CreateNVP(metric, "metric");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceSet);
|
||||
ar & BOOST_SERIALIZATION_NVP(metric);
|
||||
|
||||
// If we are loading, set the tree to NULL and clean up memory if necessary.
|
||||
if (Archive::is_loading::value)
|
||||
@@ -793,8 +791,8 @@ void RangeSearch<MetricType, MatType, TreeType>::Serialize(
|
||||
treeOwner = true;
|
||||
}
|
||||
|
||||
ar & CreateNVP(referenceTree, "referenceTree");
|
||||
ar & CreateNVP(oldFromNewReferences, "oldFromNewReferences");
|
||||
ar & BOOST_SERIALIZATION_NVP(referenceTree);
|
||||
ar & BOOST_SERIALIZATION_NVP(oldFromNewReferences);
|
||||
|
||||
// If we are loading, set the dataset accordingly and clean up memory if
|
||||
// necessary.
|
||||
|
||||
@@ -46,9 +46,9 @@ class RangeSearchStat
|
||||
|
||||
//! Serialize the statistic.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(lastDistance, "lastDistance");
|
||||
ar & BOOST_SERIALIZATION_NVP(lastDistance);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -331,7 +331,7 @@ class RSModel
|
||||
|
||||
//! Serialize the range search model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Expose the dataset.
|
||||
const arma::mat& Dataset() const;
|
||||
@@ -420,7 +420,7 @@ class RSModel
|
||||
} // namespace range
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation (of Serialize() and inline functions).
|
||||
// Include implementation (of serialize() and inline functions).
|
||||
#include "rs_model_impl.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file rs_model_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Implementation of Serialize() and inline functions for RSModel.
|
||||
* Implementation of serialize() and inline functions for RSModel.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
@@ -458,7 +458,7 @@ template<typename Archive>
|
||||
template<typename RSType>
|
||||
void SerializeVisitor<Archive>::operator()(RSType* rs) const
|
||||
{
|
||||
ar & data::CreateNVP(rs, name);
|
||||
ar & BOOST_SERIALIZATION_NVP(rs);
|
||||
}
|
||||
|
||||
//! Return whether single mode enabled
|
||||
@@ -481,13 +481,11 @@ bool& NaiveVisitor::operator()(RSType* rs) const
|
||||
|
||||
// Serialize the model.
|
||||
template<typename Archive>
|
||||
void RSModel::Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void RSModel::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
using data::CreateNVP;
|
||||
|
||||
ar & CreateNVP(treeType, "treeType");
|
||||
ar & CreateNVP(randomBasis, "randomBasis");
|
||||
ar & CreateNVP(q, "q");
|
||||
ar & BOOST_SERIALIZATION_NVP(treeType);
|
||||
ar & BOOST_SERIALIZATION_NVP(randomBasis);
|
||||
ar & BOOST_SERIALIZATION_NVP(q);
|
||||
|
||||
// This should never happen, but just in case...
|
||||
if (Archive::is_loading::value)
|
||||
|
||||
@@ -379,7 +379,7 @@ class RAModel
|
||||
|
||||
//! Serialize the model.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */);
|
||||
void serialize(Archive& ar, const unsigned int /* version */);
|
||||
|
||||
//! Expose the dataset.
|
||||
const arma::mat& Dataset() const;
|
||||
|
||||
@@ -246,7 +246,7 @@ template<typename Archive>
|
||||
template<typename RAType>
|
||||
void SerializeVisitor<Archive>::operator()(RAType*& ra) const
|
||||
{
|
||||
ar & data::CreateNVP(ra, name);
|
||||
ar & BOOST_SERIALIZATION_NVP(ra);
|
||||
}
|
||||
|
||||
//! Exposes the Naive() method of the given RAType instance.
|
||||
@@ -344,12 +344,12 @@ RAModel<SortPolicy>::~RAModel()
|
||||
|
||||
template<typename SortPolicy>
|
||||
template<typename Archive>
|
||||
void RAModel<SortPolicy>::Serialize(Archive& ar,
|
||||
void RAModel<SortPolicy>::serialize(Archive& ar,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(treeType, "treeType");
|
||||
ar & data::CreateNVP(randomBasis, "randomBasis");
|
||||
ar & data::CreateNVP(q, "q");
|
||||
ar & BOOST_SERIALIZATION_NVP(treeType);
|
||||
ar & BOOST_SERIALIZATION_NVP(randomBasis);
|
||||
ar & BOOST_SERIALIZATION_NVP(q);
|
||||
|
||||
// This should never happen, but just in case, be clean with memory.
|
||||
if (Archive::is_loading::value)
|
||||
|
||||
@@ -62,10 +62,10 @@ class RAQueryStat
|
||||
|
||||
//! Serialize the statistic.
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(bound, "bound");
|
||||
ar & data::CreateNVP(numSamplesMade, "numSamplesMade");
|
||||
ar & BOOST_SERIALIZATION_NVP(bound);
|
||||
ar & BOOST_SERIALIZATION_NVP(numSamplesMade);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user