paddle.init default use env

feature/design_of_v2_layer_converter
yi.wu 8 years ago
parent 0beda8736f
commit c1cb483a6c

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import os
import optimizer import optimizer
import layer import layer
import activation import activation
@ -42,6 +43,12 @@ __all__ = [
def init(**kwargs): def init(**kwargs):
args = [] 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(): for key in kwargs.keys():
args.append('--%s=%s' % (key, str(kwargs[key]))) args.append('--%s=%s' % (key, str(kwargs[key])))

Loading…
Cancel
Save