Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing errors occuring when training, and deprecated warning #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dependencies/jsoncpp/include/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
*Value.
*
* \deprecated Use CharReader and CharReaderBuilder.
* Use CharReader and CharReaderBuilder.
*/
class JSON_API Reader {
public:
Expand Down Expand Up @@ -111,7 +111,7 @@ class JSON_API Reader {
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
std::string getFormatedErrorMessages() const;
std::string getFormatedErrorMessages() __deprecated; //const;

/** \brief Returns a user friendly string that list errors in the parsed
* document.
Expand All @@ -120,7 +120,7 @@ class JSON_API Reader {
* in
* the parsed document. An empty string is returned if no error
* occurred
* during parsing.
* during parsing.
*/
std::string getFormattedErrorMessages() const;

Expand Down
6 changes: 3 additions & 3 deletions dependencies/jsoncpp/include/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,11 @@ Json::Value obj_value(Json::objectValue); // {}
/// \pre type() is objectValue or nullValue
/// \post type() is unchanged
/// \deprecated
Value removeMember(const char* key);
Value removeMember(const char* key) __deprecated;
/// Same as removeMember(const char*)
/// \param key may contain embedded nulls.
/// \deprecated
Value removeMember(const std::string& key);
Value removeMember(const std::string& key) __deprecated;
/// Same as removeMember(const char* begin, const char* end, Value* removed),
/// but 'key' is null-terminated.
bool removeMember(const char* key, Value* removed);
Expand Down Expand Up @@ -535,7 +535,7 @@ Json::Value obj_value(Json::objectValue); // {}

/// \deprecated Always pass len.
JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
void setComment(const char* comment, CommentPlacement placement);
void setComment(const char* comment, CommentPlacement placement) __deprecated;
/// Comments must be //... or /* ... */
void setComment(const char* comment, size_t len, CommentPlacement placement);
/// Comments must be //... or /* ... */
Expand Down
10 changes: 5 additions & 5 deletions dependencies/jsoncpp/include/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
};

/** \brief Abstract class for writers.
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
* Use StreamWriter. (And really, this is an implementation detail.)
*/
class JSON_API Writer {
public:
Expand All @@ -152,7 +152,7 @@ class JSON_API Writer {
*consumption,
* but may be usefull to support feature such as RPC where bandwith is limited.
* \sa Reader, Value
* \deprecated Use StreamWriterBuilder.
* Use StreamWriterBuilder.
*/
class JSON_API FastWriter : public Writer {

Expand Down Expand Up @@ -205,7 +205,7 @@ class JSON_API FastWriter : public Writer {
*#CommentPlacement.
*
* \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder.
* Use StreamWriterBuilder.
*/
class JSON_API StyledWriter : public Writer {
public:
Expand Down Expand Up @@ -265,9 +265,9 @@ class JSON_API StyledWriter : public Writer {
* If the Value have comments then they are outputed according to their
#CommentPlacement.
*
* \param indentation Each level will be indented by this amount extra.
* indentation Each level will be indented by this amount extra.
* \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder.
* Use StreamWriterBuilder.
*/
class JSON_API StyledStreamWriter {
public:
Expand Down
18 changes: 10 additions & 8 deletions src/core/model/xmmModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,14 @@ class Model : public Writable {
is_training_ = true;

// Fetch training set parameters
shared_parameters->dimension.set(trainingSet->dimension.get());
shared_parameters->dimension = trainingSet->dimension.get();
if (shared_parameters->bimodal.get()) {
shared_parameters->dimension_input.set(
trainingSet->dimension_input.get());
}
shared_parameters->column_names.resize(trainingSet->dimension.get());
shared_parameters->column_names.set(trainingSet->column_names.get());

// Update models
bool contLoop(true);
while (contLoop) {
Expand All @@ -275,7 +276,6 @@ class Model : public Writable {
it != trainingSet->labels().end(); ++it) {
addModelForClass(*it);
}

// Start class training
for (auto it = this->models.begin(); it != this->models.end(); ++it) {
it->second.is_training_ = true;
Expand All @@ -285,9 +285,10 @@ class Model : public Writable {
MultithreadingMode::Parallel) ||
(configuration.multithreading ==
MultithreadingMode::Background)) {
training_threads_[it->first] =
training_threads_.insert(std::pair<std::string, std::thread>(
it->first,
std::thread(&SingleClassModel::train, &it->second,
trainingSet->getPhrasesOfClass(it->first));
trainingSet->getPhrasesOfClass(it->first))));
} else {
it->second.train(trainingSet->getPhrasesOfClass(it->first));
}
Expand Down Expand Up @@ -332,21 +333,22 @@ class Model : public Writable {
is_training_ = true;

// Fetch training set parameters
shared_parameters->dimension.set(trainingSet->dimension.get());
shared_parameters->dimension = trainingSet->dimension.get();
if (shared_parameters->bimodal.get()) {
shared_parameters->dimension_input.set(
trainingSet->dimension_input.get());
}
shared_parameters->column_names.resize(trainingSet->dimension.get());
shared_parameters->column_names.set(trainingSet->column_names.get());

addModelForClass(label);

// Start class training
models[label].is_training_ = true;
models[label].cancel_training_ = false;
models_still_training_++;
if (configuration.multithreading == MultithreadingMode::Sequential) {
models[label].train(trainingSet->getPhrasesOfClass(label));
models[label].xmm::SingleClassProbabilisticModel::train(trainingSet->getPhrasesOfClass(label));
} else {
training_threads_[label] =
std::thread(&SingleClassModel::train, &(this->models[label]),
Expand Down
4 changes: 2 additions & 2 deletions src/core/model/xmmModelSingleClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ operator=(SingleClassProbabilisticModel const& src) {
throw std::runtime_error(
"Cannot copy: source model is still training");
label = src.label;
training_status = TrainingEvent(this, label),
training_status = TrainingEvent(this, label);
shared_parameters = src.shared_parameters;
is_training_ = false;
cancel_training_ = false;
Expand Down Expand Up @@ -235,4 +235,4 @@ Json::Value xmm::SingleClassProbabilisticModel::toJson() const {
Json::Value root;
root["label"] = label;
return root;
}
}
10 changes: 4 additions & 6 deletions src/models/gmm/xmmGmmSingleClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,10 @@ void xmm::SingleClassGMM::fromJson(Json::Value const& root) {
void xmm::SingleClassGMM::allocate() {
mixture_coeffs.resize(parameters.gaussians.get());
beta.resize(parameters.gaussians.get());
components.assign(
parameters.gaussians.get(),
GaussianDistribution(shared_parameters->bimodal.get(),
shared_parameters->dimension.get(),
shared_parameters->dimension_input.get(),
parameters.covariance_mode.get()));

GaussianDistribution mgaus(shared_parameters->bimodal.get(),
shared_parameters->dimension.get());
components.assign(parameters.gaussians.get(),mgaus);
}

double xmm::SingleClassGMM::obsProb(const float* observation,
Expand Down
8 changes: 7 additions & 1 deletion src/models/hmm/xmmHierarchicalHmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,20 @@ void xmm::HierarchicalHMM::updateResults() {
double normconst_instant(0.0);
double normconst_smoothed(0.0);
int i(0);
results.instant_likelihoods.resize(shared_parameters->dimension.get());
results.smoothed_log_likelihoods.resize(shared_parameters->dimension.get());
results.smoothed_likelihoods.resize(shared_parameters->dimension.get());
results.instant_normalized_likelihoods.resize(shared_parameters->dimension.get());
results.smoothed_normalized_likelihoods.resize(shared_parameters->dimension.get());

for (auto &model : models) {
results.instant_likelihoods[i] =
model.second.results.instant_likelihood;
results.smoothed_log_likelihoods[i] =
model.second.results.log_likelihood;
results.smoothed_likelihoods[i] =
exp(results.smoothed_log_likelihoods[i]);

results.instant_normalized_likelihoods[i] =
results.instant_likelihoods[i];
results.smoothed_normalized_likelihoods[i] =
Expand Down