diff --git a/.gitignore b/.gitignore
index 53c1fb056bb..4e99c067660 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,3 +93,11 @@ LOCK
LOG*
CURRENT
MANIFEST-*
+
+
+# Windows dev files
+Release/
+Debug/
+3rdparty/
+*.*sdf
+*.deps
\ No newline at end of file
diff --git a/MSVC/caffe.vcxproj b/MSVC/caffe.vcxproj
new file mode 100644
index 00000000000..6875b69c75a
--- /dev/null
+++ b/MSVC/caffe.vcxproj
@@ -0,0 +1,129 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {537EF951-4B02-4103-A310-52A6F7C8D748}
+ Win32Proj
+ caffe
+ Caffe
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)bin\$(Configuration)\
+ .exe
+ $(ProjectName)D
+ obj\$(ProjectName)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)bin\$(Configuration)\
+ .exe
+ obj\$(ProjectName)\$(Configuration)\
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;USE_CUDNN;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ Console
+ true
+ lib\$(Configuration);..\3rdparty\lib;..\3rdparty\lib;$(CUDA_PATH)\lib\$(PlatformName);%(AdditionalLibraryDirectories)
+ caffelib.lib;cudnn.lib;opencv_core249d.lib;opencv_calib3d249d.lib;opencv_contrib249d.lib;opencv_flann249d.lib;opencv_highgui249d.lib;opencv_imgproc249d.lib;opencv_legacy249d.lib;opencv_ml249d.lib;opencv_gpu249d.lib;opencv_objdetect249d.lib;opencv_photo249d.lib;opencv_features2d249d.lib;opencv_nonfree249d.lib;opencv_stitching249d.lib;opencv_video249d.lib;opencv_videostab249d.lib;cudart.lib;cuda.lib;nppi.lib;cufft.lib;cublas.lib;curand.lib;gflagsd.lib;libglog.lib;libopenblas.dll.a;libprotobufd.lib;libprotoc.lib;leveldbd.lib;lmdbd.lib;libhdf5_D.lib;libhdf5_hl_D.lib;Shlwapi.lib;%(AdditionalDependencies)
+
+
+
+ robocopy ..\3rdparty\bin $(SolutionDir)bin\$(Configuration) /xo /xn
+IF %ERRORLEVEL% GEQ 8 exit 1
+exit 0
+ Copy dlls to app folder
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;USE_CUDNN;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ Console
+ true
+ true
+ true
+ lib\$(Configuration);..\3rdparty\lib;..\3rdparty\lib;$(CUDA_PATH)\lib\$(PlatformName);%(AdditionalLibraryDirectories)
+ caffelib.lib;cudnn.lib;opencv_core249.lib;opencv_flann249.lib;opencv_imgproc249.lib;opencv_highgui249.lib;opencv_legacy249.lib;opencv_video249.lib;opencv_ml249.lib;opencv_calib3d249.lib;opencv_objdetect249.lib;opencv_stitching249.lib;opencv_gpu249.lib;opencv_nonfree249.lib;opencv_features2d249.lib;cudart.lib;cuda.lib;nppi.lib;cufft.lib;cublas.lib;curand.lib;gflags.lib;libglog.lib;libopenblas.dll.a;libprotobuf.lib;libprotoc.lib;leveldb.lib;lmdb.lib;libhdf5.lib;libhdf5_hl.lib;Shlwapi.lib;%(AdditionalDependencies)
+
+
+ robocopy ..\3rdparty\bin $(SolutionDir)bin\$(Configuration) /xo /xn
+IF %ERRORLEVEL% GEQ 8 exit 1
+exit 0
+ Copy dlls to app folder
+
+
+ true
+
+
+
+
+
+
+
+ {7f271127-d68a-4b9b-acce-1369394ed6e5}
+ false
+ true
+ false
+ true
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MSVC/caffe.vcxproj.filters b/MSVC/caffe.vcxproj.filters
new file mode 100644
index 00000000000..b94d5bc6849
--- /dev/null
+++ b/MSVC/caffe.vcxproj.filters
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MSVC/caffelib.vcxproj b/MSVC/caffelib.vcxproj
new file mode 100644
index 00000000000..7813e41ae7b
--- /dev/null
+++ b/MSVC/caffelib.vcxproj
@@ -0,0 +1,271 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {7F271127-D68A-4B9B-ACCE-1369394ED6E5}
+ Win32Proj
+ caffe
+ CaffeLib
+
+
+
+ StaticLibrary
+ true
+ v120
+ Unicode
+
+
+ StaticLibrary
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ lib\$(Configuration)\
+ .lib
+ $(ProjectName)
+ obj\$(ProjectName)\$(Configuration)\
+
+
+ false
+ lib\$(Configuration)\
+ .lib
+ obj\$(ProjectName)\$(Configuration)\
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;USE_CUDNN;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ ../scripts/GeneratePB.bat
+
+
+
+
+
+
+ $(OutDir)$(TargetName)$(TargetExt)
+
+
+ compute_35,sm_35;compute_52,sm_52;compute_52,compute_52
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;USE_CUDNN;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ ../scripts/GeneratePB.bat
+
+
+ compute_35,sm_35;compute_52,sm_52;compute_52,compute_52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MSVC/caffelib.vcxproj.filters b/MSVC/caffelib.vcxproj.filters
new file mode 100644
index 00000000000..0c081aafb5b
--- /dev/null
+++ b/MSVC/caffelib.vcxproj.filters
@@ -0,0 +1,494 @@
+
+
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files\util
+
+
+ Source Files
+
+
+ Source Files\util
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+ Source Files\layers
+
+
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+ Head Files
+
+
+
+
+ {93c9d8fe-d851-4bff-951e-ca0a847fa914}
+
+
+ {96337b54-9395-4d43-8842-41c1449332e9}
+
+
+ {5b7591ff-b0b4-4618-9be6-d8642730c68a}
+
+
+ {e7bb9e91-e346-4c51-a426-223799f528b7}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MSVC/pycaffe.vcxproj b/MSVC/pycaffe.vcxproj
new file mode 100644
index 00000000000..550a88f3c62
--- /dev/null
+++ b/MSVC/pycaffe.vcxproj
@@ -0,0 +1,117 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+ {C209DCB1-C214-4182-B340-F171BB50B45B}
+ Win32Proj
+ caffe
+ pycaffe
+ SAK
+ SAK
+ SAK
+ SAK
+
+
+
+ DynamicLibrary
+ true
+ v120
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)../bin
+ .pyd
+
+
+ false
+ $(SolutionDir)../bin
+ .pyd
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;USE_CUDNN;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ Console
+ true
+ caffelibd.lib;cudnn.lib;opencv_core249d.lib;opencv_calib3d249d.lib;opencv_contrib249d.lib;opencv_flann249d.lib;opencv_highgui249d.lib;opencv_imgproc249d.lib;opencv_legacy249d.lib;opencv_ml249d.lib;opencv_gpu249d.lib;opencv_objdetect249d.lib;opencv_photo249d.lib;opencv_features2d249d.lib;opencv_nonfree249d.lib;opencv_stitching249d.lib;opencv_video249d.lib;opencv_videostab249d.lib;cudart.lib;cuda.lib;nppi.lib;cufft.lib;cublas.lib;curand.lib;gflagsd.lib;libglog.lib;libopenblas.dll.a;libprotobufd.lib;libprotoc.lib;leveldbd.lib;lmdbd.lib;libhdf5_D.lib;libhdf5_hl_D.lib;Shlwapi.lib;%(AdditionalDependencies)
+ ..\3rdparty\lib;..\3rdparty\lib;$(CUDA_PATH)\lib\$(PlatformName);%(AdditionalLibraryDirectories)
+
+
+ ../scripts/GeneratePB.bat
+
+
+ copy /y "..\bin\caffe.lib" "..\bin\caffed.lib"
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;USE_CUDNN;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+ ..\include;..\src;..\3rdparty\include;..\3rdparty\include\openblas;..\3rdparty\include\hdf5;..\3rdparty\include\lmdb;..\3rdparty\include\opencv;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ -D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)
+
+
+ Console
+ true
+ true
+ true
+ caffelib.lib;cudnn.lib;opencv_core249.lib;opencv_flann249.lib;opencv_imgproc249.lib;opencv_highgui249.lib;opencv_legacy249.lib;opencv_video249.lib;opencv_ml249.lib;opencv_calib3d249.lib;opencv_objdetect249.lib;opencv_stitching249.lib;opencv_gpu249.lib;opencv_nonfree249.lib;opencv_features2d249.lib;cudart.lib;cuda.lib;nppi.lib;cufft.lib;cublas.lib;curand.lib;gflags.lib;libglog.lib;libopenblas.dll.a;libprotobuf.lib;libprotoc.lib;leveldb.lib;lmdb.lib;libhdf5.lib;libhdf5_hl.lib;Shlwapi.lib;python27.lib;%(AdditionalDependencies)
+ ..\3rdparty\lib;..\3rdparty\lib;$(CUDA_PATH)\lib\$(PlatformName);%(AdditionalLibraryDirectories)
+
+
+ ../scripts/GeneratePB.bat
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index ebec286d550..61eae4c553f 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,10 @@ Check out the [project site](http://caffe.berkeleyvision.org) for all the detail
and step-by-step examples.
-[![Join the chat at https://gitter.im/BVLC/caffe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/BVLC/caffe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+## Setup
+`git clone git@github.com:MSRDL/caffe.git`
-Please join the [caffe-users group](https://groups.google.com/forum/#!forum/caffe-users) or [gitter chat](https://gitter.im/BVLC/caffe) to ask questions and talk about methods and models.
-Framework development discussions and thorough bug reports are collected on [Issues](https://github.com/BVLC/caffe/issues).
-
-Happy brewing!
+For development in Windows, also run `git clone git@github.com:MSRDL/wincaffe-3rdparty.git 3rdparty` from the `caffe` folder.
## License and Citation
diff --git a/caffex.sln b/caffex.sln
new file mode 100644
index 00000000000..439c25dbb3b
--- /dev/null
+++ b/caffex.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CaffeLib", "MSVC\caffelib.vcxproj", "{7F271127-D68A-4B9B-ACCE-1369394ED6E5}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Caffe", "MSVC\caffe.vcxproj", "{537EF951-4B02-4103-A310-52A6F7C8D748}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7F271127-D68A-4B9B-ACCE-1369394ED6E5}.Debug|x64.ActiveCfg = Debug|x64
+ {7F271127-D68A-4B9B-ACCE-1369394ED6E5}.Debug|x64.Build.0 = Debug|x64
+ {7F271127-D68A-4B9B-ACCE-1369394ED6E5}.Release|x64.ActiveCfg = Release|x64
+ {7F271127-D68A-4B9B-ACCE-1369394ED6E5}.Release|x64.Build.0 = Release|x64
+ {537EF951-4B02-4103-A310-52A6F7C8D748}.Debug|x64.ActiveCfg = Debug|x64
+ {537EF951-4B02-4103-A310-52A6F7C8D748}.Debug|x64.Build.0 = Debug|x64
+ {537EF951-4B02-4103-A310-52A6F7C8D748}.Release|x64.ActiveCfg = Release|x64
+ {537EF951-4B02-4103-A310-52A6F7C8D748}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/include/caffe/common_layers.hpp b/include/caffe/common_layers.hpp
index 89bab8d6f3a..20d203dca7b 100644
--- a/include/caffe/common_layers.hpp
+++ b/include/caffe/common_layers.hpp
@@ -673,6 +673,30 @@ class TileLayer : public Layer {
unsigned int axis_, tiles_, outer_dim_, inner_dim_;
};
+template
+class MILLayer : public Layer {
+ public:
+ explicit MILLayer(const LayerParameter& param)
+ : Layer(param) {}
+ virtual void LayerSetUp(const vector*>& bottom,
+ const vector*>& top);
+ virtual void Reshape(const vector*>& bottom,
+ const vector*>& top);
+ virtual inline const char* type() const { return "MIL"; }
+ virtual inline int ExactNumBottomBlobs() const { return 1; }
+ virtual inline int ExactNumTopBlobs() const { return 1; }
+ protected:
+ virtual void Forward_cpu(const vector*>& bottom,
+ const vector*>& top);
+ // virtual Dtype Forward_gpu(const vector*>& bottom,
+ // vector*>* top);
+ virtual void Backward_cpu(const vector*>& top,
+ const vector& propagate_down, const vector*>& bottom);
+ // virtual void Backward_gpu(const vector*>& top,
+ // const vector& propagate_down, vector*>* bottom);
+
+ int channels_, height_, width_, num_images_;
+};
} // namespace caffe
#endif // CAFFE_COMMON_LAYERS_HPP_
diff --git a/include/caffe/data_layers.hpp b/include/caffe/data_layers.hpp
index 90fd0d19917..08c8c8a36d1 100644
--- a/include/caffe/data_layers.hpp
+++ b/include/caffe/data_layers.hpp
@@ -339,6 +339,39 @@ class WindowDataLayer : public BasePrefetchingDataLayer {
vector > image_database_cache_;
};
+/**
+ * @brief Uses a text file which specifies the image names, and a hdf5 file for the labels.
+ * Note that each image can have multiple positive labels.
+ *
+ * TODO(dox): thorough documentation for Forward and proto params.
+ */
+template
+class MILDataLayer : public BasePrefetchingDataLayer {
+ public:
+ explicit MILDataLayer(const LayerParameter& param);
+ virtual ~MILDataLayer();
+ virtual void DataLayerSetUp(const vector*>& bottom,
+ const vector*>& top) override;
+
+ virtual const char* type() const override;
+
+ virtual int ExactNumBottomBlobs() const override;
+
+ virtual inline int ExactNumTopBlobs() const override;
+
+protected:
+ virtual void load_batch(Batch* batch) override;
+ virtual unsigned int PrefetchRand();
+ int num_images_;
+ unsigned int counter_;
+ shared_ptr prefetch_rng_;
+ vector< std::pair > image_database_;
+ hid_t label_file_id_;
+
+ vector mean_value_;
+ Blob label_blob_;
+};
+
} // namespace caffe
#endif // CAFFE_DATA_LAYERS_HPP_
diff --git a/include/caffe/loss_layers.hpp b/include/caffe/loss_layers.hpp
index 8d41af34e88..26652acaf13 100644
--- a/include/caffe/loss_layers.hpp
+++ b/include/caffe/loss_layers.hpp
@@ -657,6 +657,23 @@ class SigmoidCrossEntropyLossLayer : public LossLayer {
vector*> sigmoid_top_vec_;
};
+/* CrossEntropyLossLayer
+*/
+template
+class CrossEntropyLossLayer : public LossLayer {
+ public:
+ explicit CrossEntropyLossLayer(const LayerParameter& param)
+ : LossLayer(param) {}
+ virtual void LayerSetUp(const vector*>& bottom,
+ const vector*>& top);
+
+ protected:
+ virtual void Forward_cpu(const vector*>& bottom,
+ const vector*>& top);
+ virtual void Backward_cpu(const vector*>& top,
+ const vector& propagate_down, const vector*>& bottom);
+};
+
// Forward declare SoftmaxLayer for use in SoftmaxWithLossLayer.
template class SoftmaxLayer;
diff --git a/include/caffe/util/cudnn.hpp b/include/caffe/util/cudnn.hpp
index b531dd5fa7a..17a4ef551e6 100644
--- a/include/caffe/util/cudnn.hpp
+++ b/include/caffe/util/cudnn.hpp
@@ -14,7 +14,7 @@
<< cudnnGetErrorString(status); \
} while (0)
-inline const char* cudnnGetErrorString(cudnnStatus_t status) {
+inline const char* CUDNNWINAPI cudnnGetErrorString(cudnnStatus_t status) {
switch (status) {
case CUDNN_STATUS_SUCCESS:
return "CUDNN_STATUS_SUCCESS";
diff --git a/include/caffe/util/hdf5.hpp b/include/caffe/util/hdf5.hpp
index ce568c5eb0d..725fcfdd45a 100644
--- a/include/caffe/util/hdf5.hpp
+++ b/include/caffe/util/hdf5.hpp
@@ -4,7 +4,6 @@
#include
#include "hdf5.h"
-#include "hdf5_hl.h"
#include "caffe/blob.hpp"
diff --git a/include/caffe/util/io.hpp b/include/caffe/util/io.hpp
index 6070b4c7f3a..e2560808473 100644
--- a/include/caffe/util/io.hpp
+++ b/include/caffe/util/io.hpp
@@ -9,6 +9,7 @@
#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/proto/caffe.pb.h"
+#include "caffe/util/msvc.hpp"
namespace caffe {
@@ -22,7 +23,11 @@ inline void MakeTempFilename(string* temp_filename) {
strcpy(temp_filename_cstr, temp_filename->c_str());
int fd = mkstemp(temp_filename_cstr);
CHECK_GE(fd, 0) << "Failed to open a temporary file at: " << *temp_filename;
- close(fd);
+#ifndef _MSC_VER
+ close(fd);
+#else
+ _close(fd);
+#endif
*temp_filename = temp_filename_cstr;
delete[] temp_filename_cstr;
}
@@ -33,7 +38,11 @@ inline void MakeTempDir(string* temp_dirname) {
char* temp_dirname_cstr = new char[temp_dirname->size() + 1];
// NOLINT_NEXT_LINE(runtime/printf)
strcpy(temp_dirname_cstr, temp_dirname->c_str());
- char* mkdtemp_result = mkdtemp(temp_dirname_cstr);
+#ifndef _MSC_VER
+ char* mkdtemp_result = mkdtemp(temp_dirname_cstr);
+#else
+ errno_t mkdtemp_result = _mktemp_s(temp_dirname_cstr, sizeof(temp_dirname_cstr));
+#endif
CHECK(mkdtemp_result != NULL)
<< "Failed to create a temporary directory at: " << *temp_dirname;
*temp_dirname = temp_dirname_cstr;
diff --git a/include/caffe/util/msvc.hpp b/include/caffe/util/msvc.hpp
new file mode 100644
index 00000000000..7dae60aeb4c
--- /dev/null
+++ b/include/caffe/util/msvc.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#ifdef _MSC_VER
+
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include
+
+#define snprintf _snprintf_s
+#define getpid _getpid
+
+#define mkdir(str, mode) _mkdir(str)
+
+#define __builtin_popcount __popcnt
+#define __builtin_popcountl __popcnt64
+
+static const char letters[] =
+"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+/* Generate a temporary file name based on TMPL. TMPL must match the
+rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
+does not exist at the time of the call to mkstemp. TMPL is
+overwritten with the result. */
+int mkstemp(char *tmpl);
+#endif // _MSC_VER
\ No newline at end of file
diff --git a/scripts/GeneratePB.bat b/scripts/GeneratePB.bat
new file mode 100644
index 00000000000..c0b32412c0f
--- /dev/null
+++ b/scripts/GeneratePB.bat
@@ -0,0 +1,8 @@
+if exist "../src/caffe/proto/caffe.pb.h" (
+ echo caffe.pb.h remains the same as before
+) else (
+ echo caffe.pb.h is being generated
+ "../3rdparty/tools/protoc" -I="../src/caffe/proto" --cpp_out="../src/caffe/proto" "../src/caffe/proto/caffe.proto"
+ copy "..\src\caffe\proto\caffe.pb.h" "..\include\caffe\caffe.pb.h"
+)
+
diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp
index 299d67d4bec..4d65062f764 100644
--- a/src/caffe/common.cpp
+++ b/src/caffe/common.cpp
@@ -3,8 +3,12 @@
#include
#include
#include
+#ifdef _MSC_VER
+#include
+#endif
#include "caffe/common.hpp"
+#include "caffe/util/msvc.hpp"
#include "caffe/util/rng.hpp"
namespace caffe {
@@ -46,7 +50,9 @@ void GlobalInit(int* pargc, char*** pargv) {
// Google logging.
::google::InitGoogleLogging(*(pargv)[0]);
// Provide a backtrace on segfault.
+#ifndef _MSC_VER // InstallFailureSignalHandler is not defined windows glog
::google::InstallFailureSignalHandler();
+#endif
}
#ifdef CPU_ONLY // CPU-only Caffe.
diff --git a/src/caffe/layers/base_data_layer.cpp b/src/caffe/layers/base_data_layer.cpp
index b90bd4e0caf..2796078cf9f 100644
--- a/src/caffe/layers/base_data_layer.cpp
+++ b/src/caffe/layers/base_data_layer.cpp
@@ -1,3 +1,5 @@
+#pragma warning ( disable : 4703 ) //REVIEW ktran: make caffe warnings free
+
#include
#include
#include
diff --git a/src/caffe/layers/bnll_layer.cu b/src/caffe/layers/bnll_layer.cu
index d963d0687d2..6c4fa42326e 100644
--- a/src/caffe/layers/bnll_layer.cu
+++ b/src/caffe/layers/bnll_layer.cu
@@ -6,7 +6,7 @@
namespace caffe {
-const float kBNLL_THRESHOLD = 50.;
+__device__ __constant__ float kBNLL_THRESHOLD = 50.;
template
__global__ void BNLLForward(const int n, const Dtype* in, Dtype* out) {
diff --git a/src/caffe/layers/contrastive_loss_layer.cpp b/src/caffe/layers/contrastive_loss_layer.cpp
index 25e167819d3..db31aec790a 100644
--- a/src/caffe/layers/contrastive_loss_layer.cpp
+++ b/src/caffe/layers/contrastive_loss_layer.cpp
@@ -53,7 +53,7 @@ void ContrastiveLossLayer::Forward_cpu(
if (legacy_version) {
loss += std::max(margin - dist_sq_.cpu_data()[i], Dtype(0.0));
} else {
- Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0);
+ Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0);
loss += dist*dist;
}
}
diff --git a/src/caffe/layers/cross_entropy_loss_layer.cpp b/src/caffe/layers/cross_entropy_loss_layer.cpp
new file mode 100644
index 00000000000..37cfe93a639
--- /dev/null
+++ b/src/caffe/layers/cross_entropy_loss_layer.cpp
@@ -0,0 +1,75 @@
+// Copyright 2014 BVLC and contributors.
+
+#include
+#include
+#include
+#include
+
+#include "caffe/layer.hpp"
+#include "caffe/vision_layers.hpp"
+#include "caffe/util/math_functions.hpp"
+#include "caffe/util/io.hpp"
+
+using std::max;
+
+namespace caffe {
+
+ template
+ void CrossEntropyLossLayer::LayerSetUp(const vector*>& bottom, const vector*>& top) {}
+
+ template
+ void CrossEntropyLossLayer::Forward_cpu(const vector*>& bottom, const vector*>& top) {
+ const Dtype* bottom_data = bottom[0]->cpu_data();
+ const Dtype* bottom_label = bottom[1]->cpu_data();
+ int count = bottom[0]->count();
+ int num = bottom[0]->num();
+ Dtype loss = 0; Dtype l;
+ for (int i = 0; i < count; ++i) {
+ if(bottom_label[i] != 0){
+ l = -bottom_label[i]*log(max(bottom_data[i],Dtype(0.00001)));
+ loss += l;
+ }
+
+ if(bottom_label[i] != 1){
+ l = -(1-bottom_label[i])*log(max((1-bottom_data[i]),Dtype(0.00001)));
+ loss += l;
+ }
+ CHECK_GE(l, 0.) << "loss is not >= 0, loss: " << l << " bottom_label: " << bottom_label[i] << " bottom_data: " << bottom_data[i];
+ }
+ top[0]->mutable_cpu_data()[0] = loss / count;
+ }
+
+template
+void CrossEntropyLossLayer::Backward_cpu(
+ const vector*>& top, const vector& propagate_down,
+ const vector*>& bottom) {
+
+ if (propagate_down[1]) {
+ LOG(FATAL) << this->type()
+ << " Layer cannot backpropagate to label inputs.";
+ }
+ if (propagate_down[0]) {
+ const Dtype* bottom_data = bottom[0]->cpu_data();
+ const Dtype* bottom_label = bottom[1]->cpu_data();
+ Dtype* bottom_diff = bottom[0]->mutable_cpu_diff();
+ int count = bottom[0]->count();
+ int num = bottom[0]->num();
+ memset(bottom_diff, 0, sizeof(Dtype) * bottom[0]->count());
+ for (int i = 0; i < count; ++i) {
+ Dtype val = 0;
+ if(bottom_label[i] != 0)
+ val = val - bottom_label[i]/max(bottom_data[i], Dtype(0.00001))/count;
+ if(bottom_label[i] != 1)
+ val = val - (-(1-bottom_label[i])/max(1-bottom_data[i], Dtype(0.00001))/count);
+
+ bottom_diff[i] = val;
+ }
+ const Dtype loss_weight = top[0]->cpu_diff()[0];
+ caffe_scal(count, loss_weight, bottom_diff);
+ }
+}
+
+INSTANTIATE_CLASS(CrossEntropyLossLayer);
+REGISTER_LAYER_CLASS(CrossEntropyLoss);
+
+} // namespace caffe
diff --git a/src/caffe/layers/mil_data_layer.cpp b/src/caffe/layers/mil_data_layer.cpp
new file mode 100644
index 00000000000..b314a10b3a4
--- /dev/null
+++ b/src/caffe/layers/mil_data_layer.cpp
@@ -0,0 +1,228 @@
+#include
+
+#include
+#include