summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorEvan Shelhamer <shelhamer@imaginarynumber.net>2016-07-11 14:03:18 -0700
committerGitHub <noreply@github.com>2016-07-11 14:03:18 -0700
commit61944afd4e948a4e2b4ef553919a886a8a8b8246 (patch)
treee116dece3b360946d3d81e663028e2827b26f7aa /python
parente4fe4ba9a0bfcff5b78e59cb28cd5f7d8adf5bf0 (diff)
parent35a9a075cdc65c86021dde4d11e3b1c05e27971b (diff)
downloadcaffeonacl-61944afd4e948a4e2b4ef553919a886a8a8b8246.tar.gz
caffeonacl-61944afd4e948a4e2b4ef553919a886a8a8b8246.tar.bz2
caffeonacl-61944afd4e948a4e2b4ef553919a886a8a8b8246.zip
Merge pull request #4351 from nitnelave/python/set_random_seed
[pycaffe] add set_random_seed to the python interface
Diffstat (limited to 'python')
-rw-r--r--python/caffe/__init__.py2
-rw-r--r--python/caffe/_caffe.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/python/caffe/__init__.py b/python/caffe/__init__.py
index e2881b89..35868a40 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
+from ._caffe import 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 dfcfd0db..bdee75ac 100644
--- a/python/caffe/_caffe.cpp
+++ b/python/caffe/_caffe.cpp
@@ -51,6 +51,8 @@ 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 set_random_seed(unsigned int seed) { Caffe::set_random_seed(seed); }
+
// For convenience, check that input files can be opened, and raise an
// exception that boost will send to Python if not (caffe could still crash
// later if the input files are disturbed before they are actually used, but
@@ -283,6 +285,7 @@ BOOST_PYTHON_MODULE(_caffe) {
// Caffe utility functions
bp::def("set_mode_cpu", &set_mode_cpu);
bp::def("set_mode_gpu", &set_mode_gpu);
+ bp::def("set_random_seed", &set_random_seed);
bp::def("set_device", &Caffe::SetDevice);
bp::def("layer_type_list", &LayerRegistry<Dtype>::LayerTypeList);