V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
zxCoder
V2EX  ›  Python

服务器上一个神经网络模型,通过 pycharm 的 ssh remote interpreter 运行和通过命令行直接 Python xxx 运行,结果居然不一样,可能是什么原因呢

  •  
  •   zxCoder · Oct 10, 2021 · 3073 views
    This topic created in 1662 days ago, the information mentioned may be changed or developed.

    同一个虚拟环境,同一份代码

    xd314697475
        1
    xd314697475  
       Oct 10, 2021
    同一种方法,多次运行的结果一样吗? remote interpreter 会有一个远程的本地的文件,直接查看本地文件和你源文件的区别
    iOiOiOiOiO
        2
    iOiOiOiOiO  
       Oct 10, 2021 via iPhone
    初始随机变量不同,cpu 和 gpu 结果也不一样
    Lirit
        3
    Lirit  
       Oct 10, 2021
    模型里 weights,biases 一些参数初始化不一样
    black938
        4
    black938  
       Oct 10, 2021   ❤️ 3
    1 、神经网络模型需要固定 seed 以保证完全一致的复现,包括但不限于 torch 的 seed 和 numpy 的 seed,可能随机的地方全都需要固定 seed
    2 、数据集 load 进来的时候如果 shuffle 了也会导致结果不一样
    weah
        5
    weah  
       Oct 11, 2021
    那每次 ssh 或者 python 的结果都是一样的吗?
    zxCoder
        6
    zxCoder  
    OP
       Oct 11, 2021
    @weah 这个是一样的,也就是说直接 ssh,然后命令行跑也能稳定复现,直接从 ide 用远程环境跑也能稳定复现,但两个结果不一样,所以我想应该不是楼上说的问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1401 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 23:59 · PVG 07:59 · LAX 16:59 · JFK 19:59
    ♥ Do have faith in what you're doing.