| 64 | |
| 65 | template <typename Dtype> |
| 66 | void SGDSolver<Dtype>::PreSolve() { |
| 67 | // Initialize the history |
| 68 | const vector<Blob<Dtype>*>& net_params = this->net_->learnable_params(); |
| 69 | history_.clear(); |
| 70 | update_.clear(); |
| 71 | temp_.clear(); |
| 72 | for (int i = 0; i < net_params.size(); ++i) { |
| 73 | const vector<int>& shape = net_params[i]->shape(); |
| 74 | history_.push_back(shared_ptr<Blob<Dtype> >(new Blob<Dtype>(shape))); |
| 75 | update_.push_back(shared_ptr<Blob<Dtype> >(new Blob<Dtype>(shape))); |
| 76 | temp_.push_back(shared_ptr<Blob<Dtype> >(new Blob<Dtype>(shape))); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | template <typename Dtype> |
| 81 | void SGDSolver<Dtype>::ClipGradients() { |