| 8 | |
| 9 | template <typename Dtype> |
| 10 | void EltwiseLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, |
| 11 | const vector<Blob<Dtype>*>& top) { |
| 12 | CHECK(this->layer_param().eltwise_param().coeff_size() == 0 |
| 13 | || this->layer_param().eltwise_param().coeff_size() == bottom.size()) << |
| 14 | "Eltwise Layer takes one coefficient per bottom blob."; |
| 15 | CHECK(!(this->layer_param().eltwise_param().operation() |
| 16 | == EltwiseParameter_EltwiseOp_PROD |
| 17 | && this->layer_param().eltwise_param().coeff_size())) << |
| 18 | "Eltwise layer only takes coefficients for summation."; |
| 19 | op_ = this->layer_param_.eltwise_param().operation(); |
| 20 | // Blob-wise coefficients for the elementwise operation. |
| 21 | coeffs_ = vector<Dtype>(bottom.size(), 1); |
| 22 | if (this->layer_param().eltwise_param().coeff_size()) { |
| 23 | for (int i = 0; i < bottom.size(); ++i) { |
| 24 | coeffs_[i] = this->layer_param().eltwise_param().coeff(i); |
| 25 | } |
| 26 | } |
| 27 | stable_prod_grad_ = this->layer_param_.eltwise_param().stable_prod_grad(); |
| 28 | } |
| 29 | |
| 30 | template <typename Dtype> |
| 31 | void EltwiseLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, |