From c1cb483a6c5cdd10956a2659dc76214004e75bb1 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Thu, 4 May 2017 22:34:35 +0800 Subject: [PATCH] paddle.init default use env --- python/paddle/v2/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/paddle/v2/__init__.py b/python/paddle/v2/__init__.py index 7c8f6ea62..7a9d3a73f 100644 --- a/python/paddle/v2/__init__.py +++ b/python/paddle/v2/__init__.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os import optimizer import layer import activation @@ -42,6 +43,12 @@ __all__ = [ def init(**kwargs): args = [] + # NOTE: append arguments if they are in ENV + for ek, ev in os.environ.iteritems(): + if ek.startswith("PADDLE_"): + args.append('--%s=%s' % (ek.replace("PADDLE_", "").lower(), str(ev))) + + # NOTE: overwrite arguments from ENV if it is in kwargs for key in kwargs.keys(): args.append('--%s=%s' % (key, str(kwargs[key]))) -- GitLab