optional PowerParameter power_param = 21;
optional WindowDataParameter window_data_param = 20;
optional ThresholdParameter threshold_param = 25;
+ optional HingeLossParameter hinge_loss_param = 29;
// DEPRECATED: The layer parameters specified as a V0LayerParameter.
// This should never be used by any code except to upgrade to the new
optional string file_name = 1;
}
+message HingeLossParameter {
+ enum Norm {
+ L1 = 0;
+ L2 = 1;
+ }
+ // Specify the Norm to use L1 or L2
+ optional Norm hinge_norm = 1 [default = L1];
+}
+
// Message that stores parameters used by ImageDataLayer
message ImageDataParameter {
// Specify the data source.
&(this->blob_top_vec_), 0, -1, -1);
}
+
+TYPED_TEST(HingeLossLayerTest, TestGradientCPUL2) {
+ LayerParameter layer_param;
+ HingeLossParameter* hinge_loss_param = layer_param.mutable_hinge_loss_param();
+ hinge_loss_param->set_hinge_norm(HingeLossParameter_Norm_L2);
+ Caffe::set_mode(Caffe::CPU);
+ HingeLossLayer<TypeParam> layer(layer_param);
+ layer.SetUp(this->blob_bottom_vec_, &this->blob_top_vec_);
+ GradientChecker<TypeParam> checker(1e-2, 2e-3, 1701, 1, 0.01);
+ checker.CheckGradientSingle(&layer, &(this->blob_bottom_vec_),
+ &(this->blob_top_vec_), 0, -1, -1);
+}
+
+TYPED_TEST(HingeLossLayerTest, TestGradientGPUL2) {
+ LayerParameter layer_param;
+ HingeLossParameter* hinge_loss_param = layer_param.mutable_hinge_loss_param();
+ hinge_loss_param->set_hinge_norm(HingeLossParameter_Norm_L2);
+ Caffe::set_mode(Caffe::GPU);
+ HingeLossLayer<TypeParam> layer(layer_param);
+ layer.SetUp(this->blob_bottom_vec_, &this->blob_top_vec_);
+ GradientChecker<TypeParam> checker(1e-2, 2e-3, 1701, 1, 0.01);
+ checker.CheckGradientSingle(&layer, &(this->blob_bottom_vec_),
+ &(this->blob_top_vec_), 0, -1, -1);
+}
} // namespace caffe