fixreprod


Namefixreprod JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://github.com/ytakefuji/fixreprod
SummaryA package for showing all seeds to be fixed
upload_time2023-08-12 11:39:56
maintainer
docs_urlNone
authoryoshiyasu takefuji
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fixreprod
This is under review.

It is still undergoing improvement.

fixreprod is an indispensable tool to solve reproducibility problems in pseudorandom numbers by fixing all seeds and deterministic algorithms used in libraries of AI systems.
The current version can take care of torch, tensorflow, gym and gymnasium with numpy, random and scipy. The program is expandable.

To run fixreprod, install it by the following command. ($) indicates the prompt from the system in the terminal.

$ pip install fixreprod

# How to run fixreprod

For example, assume reinforcement_q_learning.py is a source code. Use grep command to generate test.py.
test.py contains imported libraries which will be checked by fixreprod. The sed command sed '/^"""/,/^"""/d' removes comment lines from reinforcement_q_learning.py and saves it in reinfo.py. The first grep command removes comment lines with the first character of "#" from reinfo.py and save it in rein.py. The second grep command extracts imported libraries from rein.py and save it in test.py.

$ grep import reinforcement_q_learning.py >test.py

or To see the code only, run the following commands

$ sed '/^"""/,/^"""/d' reinforcement_q_learning.py >reinfo.py

$ grep -v '^#' reinfo.py >rein.py

$ grep import rein.py >test.py

Before running fixreprod, you must install all libraries used in the source code.
In reinforcement_q_learning.py, gym, random, numpy, and torch must be installed.

<pre>
Run fixrepdod and enter "test.py" for checking.
fixreprod will show the all seeds to be fixed to eliminate 
reproducibility problems from your code. 
9 seeds and 1 fixing deterministic algorithms are found 
  in this example.
  
$ fixreprod
Enter the source code file name: test.py
env.action_space.seed(0)
env.reset(seed=0)
np.random.seed(0)
random.Random().seed(0)
random.seed(0)
torch.Generator().manual_seed(0)        
torch.cuda.manual_seed(0)
torch.cuda.manual_seed_all(0)
torch.manual_seed(0)
torch.use_deterministic_algorithms(True)

</pre>
These generated codes should be embedded in the rein.py or reinforcement_q_learning.py. The following figure shows the reproducible result. When changing seed numbers, the different reproducible result can be obtained.

<img src='https://github.com/ytakefuji/fixreprod/raw/main/result.png' width=540 hight=480>



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ytakefuji/fixreprod",
    "name": "fixreprod",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "yoshiyasu takefuji",
    "author_email": "takefuji@keio.jp",
    "download_url": "https://files.pythonhosted.org/packages/bd/22/4f08b8ae52d663faada12a2389ca1432e16d2910515a81506219fc36f6b4/fixreprod-0.0.10.tar.gz",
    "platform": null,
    "description": "# fixreprod\nThis is under review.\n\nIt is still undergoing improvement.\n\nfixreprod is an indispensable tool to solve reproducibility problems in pseudorandom numbers by fixing all seeds and deterministic algorithms used in libraries of AI systems.\nThe current version can take care of torch, tensorflow, gym and gymnasium with numpy, random and scipy. The program is expandable.\n\nTo run fixreprod, install it by the following command. ($) indicates the prompt from the system in the terminal.\n\n$ pip install fixreprod\n\n# How to run fixreprod\n\nFor example, assume reinforcement_q_learning.py is a source code. Use grep command to generate test.py.\ntest.py contains imported libraries which will be checked by fixreprod. The sed command sed '/^\"\"\"/,/^\"\"\"/d' removes comment lines from reinforcement_q_learning.py and saves it in reinfo.py. The first grep command removes comment lines with the first character of \"#\" from reinfo.py and save it in rein.py. The second grep command extracts imported libraries from rein.py and save it in test.py.\n\n$ grep import reinforcement_q_learning.py >test.py\n\nor To see the code only, run the following commands\n\n$ sed '/^\"\"\"/,/^\"\"\"/d' reinforcement_q_learning.py >reinfo.py\n\n$ grep -v '^#' reinfo.py >rein.py\n\n$ grep import rein.py >test.py\n\nBefore running fixreprod, you must install all libraries used in the source code.\nIn reinforcement_q_learning.py, gym, random, numpy, and torch must be installed.\n\n<pre>\nRun fixrepdod and enter \"test.py\" for checking.\nfixreprod will show the all seeds to be fixed to eliminate \nreproducibility problems from your code. \n9 seeds and 1 fixing deterministic algorithms are found \n  in this example.\n  \n$ fixreprod\nEnter the source code file name: test.py\nenv.action_space.seed(0)\nenv.reset(seed=0)\nnp.random.seed(0)\nrandom.Random().seed(0)\nrandom.seed(0)\ntorch.Generator().manual_seed(0)        \ntorch.cuda.manual_seed(0)\ntorch.cuda.manual_seed_all(0)\ntorch.manual_seed(0)\ntorch.use_deterministic_algorithms(True)\n\n</pre>\nThese generated codes should be embedded in the rein.py or reinforcement_q_learning.py. The following figure shows the reproducible result. When changing seed numbers, the different reproducible result can be obtained.\n\n<img src='https://github.com/ytakefuji/fixreprod/raw/main/result.png' width=540 hight=480>\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A package for showing all seeds to be fixed",
    "version": "0.0.10",
    "project_urls": {
        "Bug Tracker": "https://github.com/ytakefuji/fixreprod",
        "Homepage": "https://github.com/ytakefuji/fixreprod"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6242b864e5a674abb47bfd1d74aeab6711b5790a9b0c9dba7e577cb637d91444",
                "md5": "631be80fd4c8428f0953f90059d90d5c",
                "sha256": "39fe1bf67f0f034b600e3aa3042302541b40e4a897fff9d81ea356f1b8cc764d"
            },
            "downloads": -1,
            "filename": "fixreprod-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "631be80fd4c8428f0953f90059d90d5c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 3562,
            "upload_time": "2023-08-12T11:39:54",
            "upload_time_iso_8601": "2023-08-12T11:39:54.528150Z",
            "url": "https://files.pythonhosted.org/packages/62/42/b864e5a674abb47bfd1d74aeab6711b5790a9b0c9dba7e577cb637d91444/fixreprod-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd224f08b8ae52d663faada12a2389ca1432e16d2910515a81506219fc36f6b4",
                "md5": "74fb094fc32024e6882b8f7abf99f281",
                "sha256": "9270d6f818fe372fc10c5f07a1d7726bb0398bc224967921fd1f3ffc27ef3290"
            },
            "downloads": -1,
            "filename": "fixreprod-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "74fb094fc32024e6882b8f7abf99f281",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3308,
            "upload_time": "2023-08-12T11:39:56",
            "upload_time_iso_8601": "2023-08-12T11:39:56.072418Z",
            "url": "https://files.pythonhosted.org/packages/bd/22/4f08b8ae52d663faada12a2389ca1432e16d2910515a81506219fc36f6b4/fixreprod-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-12 11:39:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ytakefuji",
    "github_project": "fixreprod",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fixreprod"
}
        
Elapsed time: 0.09853s