【问题标题】:Caffe Euclidean Loss Calculation over Image图像上的 Caffe 欧几里得损失计算
【发布时间】:2018-07-30 21:12:09
【问题描述】:

假设 caffe 中神经网络的输出是大小为 w x h 的图像。 还假设我正在使用大小为 N 的批量大小。

我是否正确假设欧几里得损失(由标准 caffe 层计算)对所有 w x h 值的平方误差求和,对其进行平方根,然后在批次大小 N 上取平均值?

也就是说,它不是 w x h 值的平均值?

谢谢。

PS:有没有办法在堆栈溢出中使用数学环境?

【问题讨论】:

    标签: c++ neural-network deep-learning caffe conv-neural-network


    【解决方案1】:

    根据代码,它没有对 w x h 值进行平均,也没有使用平方根。它仅在批次大小 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;
      }
    

    【讨论】:

      猜你喜欢
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 2018-11-20
      • 1970-01-01
      • 2020-11-29
      • 2018-02-14
      • 2021-03-16
      相关资源
      最近更新 更多