咖啡馆欧几里得损失计算超过图像



假设caffe中神经网络的输出是大小w x h的图像。还假设我正在使用尺寸n。

的批量尺寸

我是否可以正确地假设由标准咖啡馆层计算的欧几里得损失总和所有W x H值的平方误差,然后将其平衡,然后在批处理大小n?

上平均

也就是说,它不是在w x h值上平均吗?

谢谢。

ps:有什么方法可以在堆栈溢出中使用数学环境?

根据代码,它在w x h值上没有平均,也不使用Square-root。它仅在批处理尺寸n上平均,然后除以2。

  template <typename Dtype>
  void EuclideanLossLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>&bottom,const vector<Blob<Dtype>*>& top) {
      int count = bottom[0]->count();
      caffe_sub(count,
      bottom[0]->cpu_data(),
      bottom[1]->cpu_data(),
      diff_.mutable_cpu_data());
      Dtype dot = caffe_cpu_dot(count, diff_.cpu_data(), diff_.cpu_data());
      Dtype loss = dot / bottom[0]->num() / Dtype(2);
      top[0]->mutable_cpu_data()[0] = loss;
  }

最新更新