38 #ifndef RERANKER_TRAINING_TIME_H_
39 #define RERANKER_TRAINING_TIME_H_
59 Time() : epoch_(-1), index_(-1), absolute_index_(-1),
60 absolute_time_(clock()), time_since_last_epoch_(absolute_time_) { }
69 absolute_index_(absolute_index),
70 absolute_time_(clock()), time_since_last_epoch_(absolute_time_) { }
74 int epoch()
const {
return epoch_; }
77 int index()
const {
return index_; }
82 clock_t diff_time = clock() - absolute_time_;
83 return ((
double)diff_time) / CLOCKS_PER_SEC;
86 clock_t diff_time = clock() - time_since_last_epoch_;
87 return ((
double)diff_time) / CLOCKS_PER_SEC;
91 return os << time.
epoch() <<
"," << time.
index() <<
";"
96 std::ostringstream oss;
112 time_since_last_epoch_ = clock();
118 clock_t absolute_time_;
119 clock_t time_since_last_epoch_;
void NewEpoch()
Increments the epoch counter.
int absolute_index() const
Returns the total number of training examples seen in all epochs.
A simple class to hold the three notions of time during training: the current epoch, the current time index within the current epoch, and the absolute time index.
Time()
Constructs a new time instance, ready for its indices to be incremented.
friend ostream & operator<<(ostream &os, const Time &time)
double absolute_seconds() const
double seconds_since_last_epoch() const
Time(int epoch, int index, int absolute_index)
Constructs a new time instance with the specified time indices.
void Tick()
Increments both the time index for the current epoch and the absolute time index. ...
int epoch() const
Returns the index of the current epoch.
int index() const
Returns the index of the current training example within the current epoch.