| 9 | |
| 10 | template <typename Dtype> |
| 11 | void SoftmaxWithLossLayer<Dtype>::LayerSetUp( |
| 12 | const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { |
| 13 | LossLayer<Dtype>::LayerSetUp(bottom, top); |
| 14 | LayerParameter softmax_param(this->layer_param_); |
| 15 | softmax_param.set_type("Softmax"); |
| 16 | softmax_layer_ = LayerRegistry<Dtype>::CreateLayer(softmax_param); |
| 17 | softmax_bottom_vec_.clear(); |
| 18 | softmax_bottom_vec_.push_back(bottom[0]); |
| 19 | softmax_top_vec_.clear(); |
| 20 | softmax_top_vec_.push_back(&prob_); |
| 21 | softmax_layer_->SetUp(softmax_bottom_vec_, softmax_top_vec_); |
| 22 | |
| 23 | has_ignore_label_ = |
| 24 | this->layer_param_.loss_param().has_ignore_label(); |
| 25 | if (has_ignore_label_) { |
| 26 | ignore_label_ = this->layer_param_.loss_param().ignore_label(); |
| 27 | } |
| 28 | if (!this->layer_param_.loss_param().has_normalization() && |
| 29 | this->layer_param_.loss_param().has_normalize()) { |
| 30 | normalization_ = this->layer_param_.loss_param().normalize() ? |
| 31 | LossParameter_NormalizationMode_VALID : |
| 32 | LossParameter_NormalizationMode_BATCH_SIZE; |
| 33 | } else { |
| 34 | normalization_ = this->layer_param_.loss_param().normalization(); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | template <typename Dtype> |
| 39 | void SoftmaxWithLossLayer<Dtype>::Reshape( |