* 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. */
| 412 | * the loss function. Store non-zero loss weights in the diff blob. |
| 413 | */ |
| 414 | inline void SetLossWeights(const vector<Blob<Dtype>*>& top) { |
| 415 | const int num_loss_weights = layer_param_.loss_weight_size(); |
| 416 | if (num_loss_weights) { |
| 417 | CHECK_EQ(top.size(), num_loss_weights) << "loss_weight must be " |
| 418 | "unspecified or specified once per top blob."; |
| 419 | for (int top_id = 0; top_id < top.size(); ++top_id) { |
| 420 | const Dtype loss_weight = layer_param_.loss_weight(top_id); |
| 421 | if (loss_weight == Dtype(0)) { continue; } |
| 422 | this->set_loss(top_id, loss_weight); |
| 423 | const int count = top[top_id]->count(); |
| 424 | Dtype* loss_multiplier = top[top_id]->mutable_cpu_diff(); |
| 425 | caffe_set(count, loss_weight, loss_multiplier); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | private: |
| 431 | /** Whether this layer is actually shared by other nets*/ |
nothing calls this directly
no test coverage detected