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

Method TestBackward

src/caffe/test/test_power_layer.cpp:61–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 }
60
61 void TestBackward(Dtype power, Dtype scale, Dtype shift) {
62 LayerParameter layer_param;
63 layer_param.mutable_power_param()->set_power(power);
64 layer_param.mutable_power_param()->set_scale(scale);
65 layer_param.mutable_power_param()->set_shift(shift);
66 PowerLayer<Dtype> layer(layer_param);
67 if (power != Dtype(0) && power != Dtype(1) && power != Dtype(2)) {
68 // Avoid NaNs by forcing (shift + scale * x) >= 0
69 Dtype* bottom_data = this->blob_bottom_->mutable_cpu_data();
70 Dtype min_value = -shift / scale;
71 for (int i = 0; i < this->blob_bottom_->count(); ++i) {
72 if (bottom_data[i] < min_value) {
73 bottom_data[i] = min_value + (min_value - bottom_data[i]);
74 }
75 }
76 }
77 GradientChecker<Dtype> checker(1e-3, 1e-2, 1701, 0., 0.01);
78 checker.CheckGradientEltwise(&layer, this->blob_bottom_vec_,
79 this->blob_top_vec_);
80 }
81
82 Blob<Dtype>* const blob_bottom_;
83 Blob<Dtype>* const blob_top_;

Callers 1

TYPED_TESTFunction · 0.45

Calls 4

set_scaleMethod · 0.80
countMethod · 0.80
CheckGradientEltwiseMethod · 0.80
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected