Skip to content

Commit

Permalink
Remove deprecated Trainer::update_epoch (#852)
Browse files Browse the repository at this point in the history
* Remove deprecated Trainer::update_epoch

It was deprecated in #695.

* Remove first variable from examples
  • Loading branch information
tetsuok authored and neubig committed Sep 4, 2017
1 parent 87df341 commit cb24072
Show file tree
Hide file tree
Showing 18 changed files with 0 additions and 38 deletions.
2 changes: 0 additions & 2 deletions examples/cpp/embed-cl/train_embed-cl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
// int report = 0;
// unsigned dev_every_i_reports = 10;
unsigned lines = 0;
Expand All @@ -156,7 +155,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
random_shuffle(order.begin(), order.end());
}
Expand Down
3 changes: 0 additions & 3 deletions examples/cpp/encdec/train_encdec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,9 @@ int main(int argc, char** argv) {
vector<unsigned> order(num_batches);
for (unsigned i = 0; i < num_batches; ++i) order[i] = i;

bool first = true;
int epoch = 0;
// Run for the given number of epochs (or indefinitely if params.NUM_EPOCHS is negative)
while (epoch < params.NUM_EPOCHS || params.NUM_EPOCHS < 0) {
// Update the optimizer
if (first) { first = false; } else { adam->update_epoch(); }
// Reshuffle the dataset
cerr << "**SHUFFLE\n";
random_shuffle(order.begin(), order.end());
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/imdb/train_imdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
TextFileSaver saver("imdb.model");
Expand All @@ -265,7 +264,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/mlc/train_mlc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ int main(int argc, char** argv) {

unsigned report_every_i = 50;
unsigned si = train.size();
bool first = true;
vector<unsigned> order(train.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
double ti = 0;
Expand All @@ -145,7 +144,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == train.size()) {
si = 0;
if (first) { first = false; } else { sgd.update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
3 changes: 0 additions & 3 deletions examples/cpp/mnist/train_mnist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ int main(int argc, char** argv) {
vector<unsigned> order(num_batches);
for (unsigned i = 0; i < num_batches; ++i) order[i] = i;

bool first = true;
unsigned epoch = 0;
vector<Expression> cur_batch;
vector<unsigned> cur_labels;

// Run for the given number of epochs (or indefinitely if params.NUM_EPOCHS is negative)
while (epoch < params.NUM_EPOCHS || params.NUM_EPOCHS < 0) {
// Update the optimizer
if (first) { first = false; } else { adam.update_epoch(); }
// Reshuffle the dataset
cerr << "**SHUFFLE\n";
random_shuffle(order.begin(), order.end());
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/poisson-regression/train_poisson-regression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -159,7 +158,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/rnnlm-aevb/train_rnnlm-aevb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -206,7 +205,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
3 changes: 0 additions & 3 deletions examples/cpp/rnnlm-batch/train_rnnlm-batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,9 @@ int main(int argc, char** argv) {
vector<unsigned> order(num_batches);
for (unsigned i = 0; i < num_batches; ++i) order[i] = i;

bool first = true;
unsigned epoch = 0;
// Run for the given number of epochs (or indefinitely if params.NUM_EPOCHS is negative)
while (epoch < params.NUM_EPOCHS || params.NUM_EPOCHS < 0) {
// Update the optimizer
if (first) { first = false; } else { adam->update_epoch(); }
// Reshuffle the dataset
cerr << "**SHUFFLE\n";
random_shuffle(order.begin(), order.end());
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/rnnlm-cfsm/train_rnnlm-cfsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -169,7 +168,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/rnnlm-final-batch/train_rnnlm-final-batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ int main(int argc, char** argv) {
vector<unsigned> order((training.size() + BATCH_SIZE - 1) / BATCH_SIZE);
unsigned si = order.size();
for (unsigned i = 0; i < order.size(); ++i) order[i] = i * BATCH_SIZE;
bool first = true;
int report = 0;
unsigned lines = 0;
while (1) {
Expand All @@ -219,7 +218,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i, ++si) {
if (si == order.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/rnnlm-givenbag/rnnlm-givenbag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
vector<unsigned> rows;
Expand All @@ -191,7 +190,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/rnnlm/train_rnnlm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ int main(int argc, char** argv) {
if (report_every_i > si) report_every_i = si;
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
double lines = 0;
int completed_epoch = -1;
Expand All @@ -265,7 +264,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
completed_epoch++;
if (eta_decay_onset_epoch && completed_epoch >= (int)eta_decay_onset_epoch)
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/segrnn-sup/train_segrnn-sup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -1105,7 +1104,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/skiprnnlm/train_skiprnnlm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -153,7 +152,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
LOG(INFO) << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/tag-bilstm/train_tag-bilstm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -215,7 +214,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/textcat/train_textcat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ int main(int argc, char** argv) {
unsigned si = training.size();
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
int report = 0;
unsigned lines = 0;
while(1) {
Expand All @@ -262,7 +261,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
2 changes: 0 additions & 2 deletions examples/cpp/tok-embed/train_tok-embed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ int main(int argc, char** argv) {
cerr << "Parameters allocated.\n";
vector<unsigned> order(training.size());
for (unsigned i = 0; i < order.size(); ++i) order[i] = i;
bool first = true;
// int report = 0;
unsigned lines = 0;
unsigned report_every_i = 50;
Expand All @@ -274,7 +273,6 @@ int main(int argc, char** argv) {
for (unsigned i = 0; i < report_every_i; ++i) {
if (si == training.size()) {
si = 0;
if (first) { first = false; } else { sgd->update_epoch(); }
cerr << "**SHUFFLE\n";
shuffle(order.begin(), order.end(), *rndeng);
}
Expand Down
1 change: 0 additions & 1 deletion examples/cpp/xor-xent/train_xor-xent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ int main(int argc, char** argv) {
cg.backward(loss_expr);
sgd.update();
}
sgd.update_epoch();
loss /= 4;
cerr << "E = " << loss << endl;
}
Expand Down

0 comments on commit cb24072

Please sign in to comment.