Skip to content

Commit

Permalink
Merge pull request HIT-SCIR#126 from endyul/hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneplus committed Aug 10, 2015
2 parents 5693a9b + 0e0ebdf commit c05d7e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/ner/ner_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ void NamedEntityRecognizerFrontend::train(void) {
INFO_LOG("report: allocate %d dimensition parameter.", model->space.dim());

int nr_groups = model->space.num_groups();
std::vector<int> groupwise_update_counters;
std::vector<size_t> update_counts;
if (train_opt.rare_feature_threshold > 0) {
groupwise_update_counters.resize(nr_groups, 0);
update_counts.resize(nr_groups, 0);
INFO_LOG("report: allocate %d update-time counters", nr_groups);
} else {
INFO_LOG("report: model truncation is inactived.");
Expand All @@ -203,7 +203,6 @@ void NamedEntityRecognizerFrontend::train(void) {
int best_iteration = -1;
double best_f_score = -1.;

std::vector<size_t> update_counts;
if (train_opt.rare_feature_threshold > 0) {
update_counts.resize(nr_groups, 0);
INFO_LOG("report: allocate %d update-time counters", nr_groups);
Expand Down Expand Up @@ -232,7 +231,7 @@ void NamedEntityRecognizerFrontend::train(void) {
updated_features.add(ctx.predict_features, -1.);

learn(train_opt.algorithm, updated_features,
iter*train_dat.size()+1, inst->num_errors(), model);
iter*train_dat.size() + i + 1, inst->num_errors(), model);

if (train_opt.rare_feature_threshold > 0) {
increase_groupwise_update_counts(model, updated_features, update_counts);
Expand Down
7 changes: 3 additions & 4 deletions src/postagger/postagger_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void PostaggerFrontend::train(void) {
INFO_LOG("report: allocate %d dimensition parameter.", model->space.dim());

int nr_groups = model->space.num_groups();
std::vector<int> groupwise_update_counters;
std::vector<size_t> update_counts;

if (train_opt.rare_feature_threshold > 0) {
groupwise_update_counters.resize(nr_groups, 0);
update_counts.resize(nr_groups, 0);
INFO_LOG("report: allocate %d update-time counters", nr_groups);
} else {
INFO_LOG("report: model truncation is inactived.");
Expand All @@ -158,7 +158,6 @@ void PostaggerFrontend::train(void) {
int best_iteration = -1;
double best_p = -1.;

std::vector<size_t> update_counts;

for (int iter = 0; iter < train_opt.max_iter; ++ iter) {
INFO_LOG("Training iteraition #%d", (iter + 1));
Expand All @@ -179,7 +178,7 @@ void PostaggerFrontend::train(void) {
updated_features.add(ctx.predict_features, -1.);

learn(train_opt.algorithm, updated_features,
iter*train_dat.size() + 1, inst->num_errors(), model);
iter*train_dat.size() + i + 1, inst->num_errors(), model);


if (train_opt.rare_feature_threshold > 0) {
Expand Down
5 changes: 2 additions & 3 deletions src/segmentor/segmentor_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ void SegmentorFrontend::train(void) {
INFO_LOG("report: allocate %d dimensition parameter.", model->space.dim());

int nr_groups = model->space.num_groups();
std::vector<int> groupwise_update_counters;
std::vector<size_t> update_counts;

// If the rare feature threshold is used, allocate memory for the
// feature group updated time.
if (train_opt.rare_feature_threshold > 0) {
groupwise_update_counters.resize(nr_groups, 0);
update_counts.resize(nr_groups, 0);
INFO_LOG("report: allocate %d update-time counters", nr_groups);
} else {
INFO_LOG("report: model truncation is inactived.");
Expand All @@ -335,7 +335,6 @@ void SegmentorFrontend::train(void) {
int best_iteration = -1;
double best_p = -1., best_r = -1., best_f = -1.;

std::vector<size_t> update_counts;
for (size_t iter = 0; iter < train_opt.max_iter; ++ iter) {
INFO_LOG("Training iteration #%d", (iter + 1));

Expand Down

0 comments on commit c05d7e4

Please sign in to comment.