Skip to main content

Easy-to-use unified tools for NN logging and managing.

Project description

Nine Six

Unified tools for Neural Network logging and managing.

Quick Start

Use pip to install Nine Six modules.

pip3 install ninesix

Pretty Logging

from ninesix import Logger # import logger
logger = Logger("example_nn") # Initialize logger

if __name__ == '__main__':
    parser = argparse.ArgumentParser() # Define your argument parser
    ... 
    args = parser.args()
    args = logger.config(args, "argparse") # Wrap the argparse object to log config

    logger.msg("We're going to start training...") # Log text message
    ... # Prepare your model
    for epoch in range(args.epoch):
        logger.progress("epoch", epoch + 1, total=args.epoch) # Record epoch as a progress variable
        ... # Train your model
        logger.value({"loss": loss, "f1": f1}) # Log value(s) associated with progress variable(s)
        ...
    logger.unwatch("epoch") # Unregister progress variable
    ...
    logger.value({"final_f1": final_f1}) # Log value(s)
    logger.msg("All done, have fun!") # Log text message

The output you will get at stdout:

2019-05-14 17:29:09 [Log] (log.py: 44 in __init__()):
Logger [example_nn] Initialized.

2019-05-14 17:29:09 [Config] (example.py: 189 in <module>()):
{
    "epoch": 300,
    "lr": 0.01,
    "lr_decay": 0.0001
}

2019-05-14 17:29:11 [Log] (example.py: 171 in <module>()):
We're going to start training...

2019-05-14 17:29:22 [Log] (example.py: 237 in <module>()):
epoch     : 300 / 300                                       
------------------------------------------------------------------
loss: 0.22311973571777344  f1: 90.58  

2019-05-14 17:29:22 [Log] (example.py: 247 in <module>()):
final_f1: 90.58

2019-05-14 17:29:11 [Log] (example.py: 371 in <module>()):
All done, have fun!

At the same time, you'll get a JSON log file ~/96log/example_nn/2019-05-14/172909.json:

[{"type": "msg", "tag": "Log", "time": "2019-05-14 17:29:09", "content": "JSON Writer Initialized."},
{"type": "config", "tag": "Log", "time": "2019-05-14 17:29:09", "content": {"lr": 0.01, "lr_decay": 0.0001, "epoch": 300}},
{"type": "msg", "tag": "Log", "time": "2019-05-14 17:29:11", "content": "We're going to start training..."},
{"type": "value", "tag": "Log", "time": "2019-05-14 17:29:12", "content": {"progress": {"epoch": {"current": 50, "max": 300}}, "value": {"loss": 5.2108306884765625, "f1": 73.26}}},
{"type": "value", "tag": "Log", "time": "2019-05-14 17:29:13", "content": {"progress": {"epoch": {"current": 100, "max": 300}}, "value": {"loss": 1.3068847656252345, "f1": 85.81}}},
...
{"type": "value", "tag": "Log", "time": "2019-05-14 17:29:22", "content": {"progress": {"epoch": {"current": 300, "max": 300}}, "value": {"loss": 0.22311973571777344, "f1": 90.58}}},
{"type": "value", "tag": "Log", "time": "2019-05-14 17:29:22", "content": {"progress": {}, "value": {"final_f1": 90.58}}},
{"type": "msg", "tag": "Log", "time": "2019-05-14 17:29:11", "content": "All done, have fun!"}]

You can try example.py which is a complete example.

Grid Search

Command Line:

96grid -p lr 0.1 0.01 0.001 -p epoch 100 to 201 jump 50 -g 1 2 3 -c "python example.py"

You can use python3 ninesix/tool/grid.py -h for more help.

Python code:

from ninesix import GridSearch

gs = GridSearch()
# set environment settings
gs.cmd_env = ""
# set default command
gs.cmd_template = "python3 example.py" 
# set available GPUs
gs.gpus = [0]
# set parameter options
gs.param_grid = {
    "lr": [0.1, 0.01, 0.001],
    "epoch": [100, 150, 200]
}
# generate scripts
gs.generate_grid_search()
# execute scripts
gs.execute_script()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ninesix-0.0.4.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ninesix-0.0.4-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file ninesix-0.0.4.tar.gz.

File metadata

  • Download URL: ninesix-0.0.4.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

File hashes

Hashes for ninesix-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6a215f9acfc2ceae8dc737dfccad2bfe3bac6c14d67d6e70bf2d7eae42d61e7f
MD5 e8e04562c71692628232de194aead114
BLAKE2b-256 a83a50dc16d6ce3b4b9c5e581c7ba91b74003ca8461f1342a1759e32adac052c

See more details on using hashes here.

File details

Details for the file ninesix-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ninesix-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

File hashes

Hashes for ninesix-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa3924e3c2ff376e52dc5c719bfc41334080956cb7d982df7cdd89aa5198d6bf
MD5 09f56c8ccf06bfb8609f72809a51c40c
BLAKE2b-256 891fcfe560417061fcb1d07414b783cd4eab69be91e94c648599f6cd41f5a60c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page