Skip to content

建议对python/paddle/trainer_config_helpers/math.py进行更名 #903

Closed

Description

@pengli09

目前在写网络config时,都会使用from paddle.trainer_config_helpers import *,此时会将python/paddle/trainer_config_helpers/math.py导入命名空间,与python自带的math库发生名字冲突。一方面由此引发报错时很难追查,另一方面如果需要同时使用二者时,会比较麻烦。因此建议对该文件名进行修改,或在python/paddle/trainer_config_helpers/init.py将import math修改为import math as NEW_NAME

该问题已导致SRL demo无法运行:db_lstm.py中先导入系统库math,然后通过from paddle.trainer_config_helpers import * 意外导入paddle.trainer_config_helpers.math,将系统库math覆盖,引起db_lstm.py第116行找不到sqrt()定义。

Activity

  1. reyoung commented on Dec 15, 2016

    @reyoung
    Collaborator

    有道理。

  2. self-assigned this
    on Dec 15, 2016
  3. added a commit that references this issue on Dec 16, 2016
    54cb6bd
  4. pengli09 commented on Dec 22, 2016

    @pengli09
    CollaboratorAuthor

    #922 的解法还是不能正确解决这个问题,#922 只是又额外引入了一个新名字layer_math,import *的时候还是会把math导入到当前命名空间中。

  5. added a commit that references this issue on Dec 26, 2016
    685299c
  6. added a commit that references this issue on Sep 25, 2019
  7. added a commit that references this issue on Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions