MCPcopy Create free account
hub / github.com/BVLC/caffe / SetLossWeights

Method SetLossWeights

include/caffe/layer.hpp:389–403  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 5

set_lossMethod · 0.95
caffe_setFunction · 0.85
countMethod · 0.80
mutable_cpu_diffMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected