summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/caffe/__init__.py2
-rw-r--r--python/caffe/_caffe.cpp16
2 files changed, 17 insertions, 1 deletions
diff --git a/python/caffe/__init__.py b/python/caffe/__init__.py
index 35868a40..5fc6ec9b 100644
--- a/python/caffe/__init__.py
+++ b/python/caffe/__init__.py
@@ -1,5 +1,5 @@
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
-from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed
+from ._caffe import init_log, log, set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed
from ._caffe import __version__
from .proto.caffe_pb2 import TRAIN, TEST
from .classifier import Classifier
diff --git a/python/caffe/_caffe.cpp b/python/caffe/_caffe.cpp
index bdee75ac..0a86045b 100644
--- a/python/caffe/_caffe.cpp
+++ b/python/caffe/_caffe.cpp
@@ -51,6 +51,19 @@ const int NPY_DTYPE = NPY_FLOAT32;
void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); }
void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); }
+void InitLog(int level) {
+ FLAGS_logtostderr = 1;
+ FLAGS_minloglevel = level;
+ ::google::InitGoogleLogging("");
+ ::google::InstallFailureSignalHandler();
+}
+void InitLogInfo() {
+ InitLog(google::INFO);
+}
+void Log(const string& s) {
+ LOG(INFO) << s;
+}
+
void set_random_seed(unsigned int seed) { Caffe::set_random_seed(seed); }
// For convenience, check that input files can be opened, and raise an
@@ -283,6 +296,9 @@ BOOST_PYTHON_MODULE(_caffe) {
bp::scope().attr("__version__") = AS_STRING(CAFFE_VERSION);
// Caffe utility functions
+ bp::def("init_log", &InitLog);
+ bp::def("init_log", &InitLogInfo);
+ bp::def("log", &Log);
bp::def("set_mode_cpu", &set_mode_cpu);
bp::def("set_mode_gpu", &set_mode_gpu);
bp::def("set_random_seed", &set_random_seed);