* Called by SetUp to initialize the weights associated with any top blobs in * the loss function. Store non-zero loss weights in the diff blob. */
| 387 | * the loss function. Store non-zero loss weights in the diff blob. |
| 388 | */ |
| 389 | inline void SetLossWeights(const vector<Blob<Dtype>*>& top) { |
| 390 | const int num_loss_weights = layer_param_.loss_weight_size(); |
| 391 | if (num_loss_weights) { |
| 392 | CHECK_EQ(top.size(), num_loss_weights) << "loss_weight must be " |
| 393 | "unspecified or specified once per top blob."; |
| 394 | for (int top_id = 0; top_id < top.size(); ++top_id) { |
| 395 | const Dtype loss_weight = layer_param_.loss_weight(top_id); |
| 396 | if (loss_weight == Dtype(0)) { continue; } |
| 397 | this->set_loss(top_id, loss_weight); |
| 398 | const int count = top[top_id]->count(); |
| 399 | Dtype* loss_multiplier = top[top_id]->mutable_cpu_diff(); |
| 400 | caffe_set(count, loss_weight, loss_multiplier); |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | private: |
| 406 | DISABLE_COPY_AND_ASSIGN(Layer); |
nothing calls this directly
no test coverage detected