#define HDF5_DATA_DATASET_NAME "data"
#define HDF5_DATA_LABEL_NAME "label"
-template <typename Dtype>
-class HDF5OutputLayer : public Layer<Dtype> {
- public:
- explicit HDF5OutputLayer(const LayerParameter& param);
- virtual ~HDF5OutputLayer();
- virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top) {}
-
- virtual inline LayerParameter_LayerType type() const {
- return LayerParameter_LayerType_HDF5_OUTPUT;
- }
- // TODO: no limit on the number of blobs
- virtual inline int ExactNumBottomBlobs() const { return 2; }
- virtual inline int ExactNumTopBlobs() const { return 0; }
-
- inline std::string file_name() const { return file_name_; }
-
- protected:
- virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
- const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
- virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
- const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
- virtual void SaveBlobs();
-
- std::string file_name_;
- hid_t file_id_;
- Blob<Dtype> data_blob_;
- Blob<Dtype> label_blob_;
-};
-
-
-template <typename Dtype>
-class HDF5DataLayer : public Layer<Dtype> {
- public:
- explicit HDF5DataLayer(const LayerParameter& param)
- : Layer<Dtype>(param) {}
- virtual ~HDF5DataLayer();
- virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
-
- virtual inline LayerParameter_LayerType type() const {
- return LayerParameter_LayerType_HDF5_DATA;
- }
- virtual inline int ExactNumBottomBlobs() const { return 0; }
- virtual inline int ExactNumTopBlobs() const { return 2; }
-
- protected:
- virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
- const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {}
- virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
- const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {}
- virtual void LoadHDF5FileData(const char* filename);
-
- std::vector<std::string> hdf_filenames_;
- unsigned int num_files_;
- unsigned int current_file_;
- hsize_t current_row_;
- Blob<Dtype> data_blob_;
- Blob<Dtype> label_blob_;
-};
-
// TODO: DataLayer, ImageDataLayer, and WindowDataLayer all have the
// same basic structure and a lot of duplicated code.
vector<bool> refill_;
};
+template <typename Dtype>
+class HDF5DataLayer : public Layer<Dtype> {
+ public:
+ explicit HDF5DataLayer(const LayerParameter& param)
+ : Layer<Dtype>(param) {}
+ virtual ~HDF5DataLayer();
+ virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+
+ virtual inline LayerParameter_LayerType type() const {
+ return LayerParameter_LayerType_HDF5_DATA;
+ }
+ virtual inline int ExactNumBottomBlobs() const { return 0; }
+ virtual inline int ExactNumTopBlobs() const { return 2; }
+
+ protected:
+ virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {}
+ virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {}
+ virtual void LoadHDF5FileData(const char* filename);
+
+ std::vector<std::string> hdf_filenames_;
+ unsigned int num_files_;
+ unsigned int current_file_;
+ hsize_t current_row_;
+ Blob<Dtype> data_blob_;
+ Blob<Dtype> label_blob_;
+};
+
+template <typename Dtype>
+class HDF5OutputLayer : public Layer<Dtype> {
+ public:
+ explicit HDF5OutputLayer(const LayerParameter& param);
+ virtual ~HDF5OutputLayer();
+ virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {}
+
+ virtual inline LayerParameter_LayerType type() const {
+ return LayerParameter_LayerType_HDF5_OUTPUT;
+ }
+ // TODO: no limit on the number of blobs
+ virtual inline int ExactNumBottomBlobs() const { return 2; }
+ virtual inline int ExactNumTopBlobs() const { return 0; }
+
+ inline std::string file_name() const { return file_name_; }
+
+ protected:
+ virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
+ virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
+ virtual void SaveBlobs();
+
+ std::string file_name_;
+ hid_t file_id_;
+ Blob<Dtype> data_blob_;
+ Blob<Dtype> label_blob_;
+};
+
// This function is used to create a pthread that prefetches the data.
template <typename Dtype>
void* ImageDataLayerPrefetch(void* layer_pointer);