--- /dev/null
+// Copyright 2014 BVLC and contributors.
+
+#include <vector>
+
+#include "caffe/layer.hpp"
+#include "caffe/vision_layers.hpp"
+
+
+namespace caffe {
+
+template <typename Dtype>
+void ThresholdLayer<Dtype>::SetUp(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
+ NeuronLayer<Dtype>::SetUp(bottom, top);
+ threshold_ = this->layer_param_.threshold_param().threshold();
+}
+
+template <typename Dtype>
+Dtype ThresholdLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
+ const Dtype* bottom_data = bottom[0]->cpu_data();
+ Dtype* top_data = (*top)[0]->mutable_cpu_data();
+ const int count = bottom[0]->count();
+ for (int i = 0; i < count; ++i) {
+ top_data[i] = ( bottom_data[i] > threshold_) ? Dtype(1) : Dtype(0);
+ }
+ return Dtype(0);
+}
+
+INSTANTIATE_CLASS(ThresholdLayer);
+
+} // namespace caffe