src/lstm/lstm.cpp
void LSTM::SetEnableTraining(TrainingState state) {
  if (state == TS_RE_ENABLE) {
    // Enable only from temp disabled.
    if (training_ == TS_TEMP_DISABLE) {
      training_ = TS_ENABLED;
    }
  } else if (state == TS_TEMP_DISABLE) {
    // Temp disable only from enabled.
    if (training_ == TS_ENABLED) {
      training_ = state;
    }
  } else {
    if (state == TS_ENABLED && training_ != TS_ENABLED) {
      for (int w = 0; w < WT_COUNT; ++w) {
        if (w == GFS && !Is2D()) {
          continue;
        }
        gate_weights_[w].InitBackward();
      }
    }
    training_ = state;
  }
  if (softmax_ != nullptr) {
    softmax_->SetEnableTraining(state);
  }
}
// Suspends/Enables training by setting the training_ flag. Serialize and
// DeSerialize only operate on the run-time data if state is false.
Suspends/Enables training by setting the training_ flag. Serialize and
DeSerialize only operate on the run-time data if state is false.
Suspends / Enables training by setting the training_ flag . Serialize and DeSerialize only operate on the run - time data if state is false .
void LSTM::SetEnableTraining(TrainingState state) {
  if (state == TS_RE_ENABLE) {
    if (training_ == TS_TEMP_DISABLE) {
      training_ = TS_ENABLED;
    }
  } else if (state == TS_TEMP_DISABLE) {
    if (training_ == TS_ENABLED) {
      training_ = state;
    }
  } else {
    if (state == TS_ENABLED && training_ != TS_ENABLED) {
      for (int w = 0; w < WT_COUNT; ++w) {
        if (w == GFS && !Is2D()) {
          continue;
        }
        gate_weights_[w].InitBackward();
      }
    }
    training_ = state;
  }
  if (softmax_ != nullptr) {
    softmax_->SetEnableTraining(state);
  }
}
void LSTM :: SetEnableTraining ( TrainingState state ) { if ( state == TS_RE_ENABLE ) { if ( training_ == TS_TEMP_DISABLE ) { training_ = TS_ENABLED ; } } else if ( state == TS_TEMP_DISABLE ) { if ( training_ == TS_ENABLED ) { training_ = state ; } } else { if ( state == TS_ENABLED && training_ != TS_ENABLED ) { for ( int w = 0 ; w < WT_COUNT ; ++ w ) { if ( w == GFS && ! Is2D ( ) ) { continue ; } gate_weights_ [ w ] . InitBackward ( ) ; } } training_ = state ; } if ( softmax_ != nullptr ) { softmax_ -> SetEnableTraining ( state ) ; } }
Suspends/Enables training by setting the training_ flag.
Suspends / Enables training by setting the training_ flag .
// Enable only from temp disabled. // Temp disable only from enabled.