{"id":19707002,"url":"https://github.com/geyang/tf_logger","last_synced_at":"2026-05-06T15:34:46.823Z","repository":{"id":57474863,"uuid":"114288226","full_name":"geyang/tf_logger","owner":"geyang","description":"logging utility for tensorboard","archived":false,"fork":false,"pushed_at":"2018-04-17T04:35:53.000Z","size":2315,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-15T21:33:59.947Z","etag":null,"topics":["pytorch","tensorboard","tensorboard-visualizations","tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geyang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-14T19:26:14.000Z","updated_at":"2024-05-14T13:20:30.000Z","dependencies_parsed_at":"2022-09-10T02:22:26.016Z","dependency_job_id":null,"html_url":"https://github.com/geyang/tf_logger","commit_stats":null,"previous_names":["episodeyang/tf_logger"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geyang%2Ftf_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geyang%2Ftf_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geyang%2Ftf_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geyang%2Ftf_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geyang","download_url":"https://codeload.github.com/geyang/tf_logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241023686,"owners_count":19896112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytorch","tensorboard","tensorboard-visualizations","tensorflow"],"created_at":"2024-11-11T21:37:39.029Z","updated_at":"2026-05-06T15:34:46.795Z","avatar_url":"https://github.com/geyang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TF_Logger, A Tensorboard Logging Utility for Non-Tensorflow Python Projects\n\n```bash\npip install tf_logger\n```\n\n## Usage\n\n```python\nfrom tf_logger import TF_Logger\n\nlogger = TF_Logger(log_directory=\"/tmp/logs/tf_logger_test/\")\n\nlogger.log(index=3, note='this is a log entry!')\nlogger.flush()\n\n# Images\nface = scipy.misc.face()\nface_bw = scipy.misc.face(gray=True)\nlogger.log_image(index=4, color_image=face, black_white=face_bw)\n    image_bw = np.zeros((64, 64, 1))\n    image_bw_2 = scipy.misc.face(gray=True)[::4, ::4]\n    \n# now print a stack\nfor i in range(10):\n    logger.log_image(i, animation=[face] * 5)\n```\n\n![logging images using tf_logger](./figures/logging_images.png)\n\n\u003e I'm planning on writing a better ML dashboard in the future.\n\nThis version of logger is integrated with `tensorboard` and at the same time prints the data in a tabular format to your `stdout`.\n- can silence `stdout` per key (per `logger.log` call)\n- can print with color: `logger.log(timestep, some_key=green(some_data))`\n- can print with custom formatting: `logger.log(timestep, some_key=green(some_data, percent))` where `percent`\n- uses the correct `unix` table characters (please stop using `|` and `+`. **Use `│`, `┼` instead**)\n\nA typical print out of this logger look like the following:\n\n```python\nfrom tf_logger import TF_Logger\n\nlogger = TF_Logger(log_directory=f\"/mnt/bucket/deep_Q_learning/{datetime.now(%Y%m%d-%H%M%S.%f):}\")\n\nlogger.log_params(G=vars(G), RUN=vars(RUN), Reporting=vars(Reporting))\n```\noutputs the following\n\n![example_real_log_output](./figures/example_log_output.png)\n\nAnd the data from multiple experiments can be views with tensorboard. \n\n![tensorboard_example](./figures/tensorboard_example.png)\n\n```log\n═════════════════════════════════════════════════════\n              G               \n───────────────────────────────┬─────────────────────\n           env_name            │ MountainCar-v0      \n             seed              │ None                \n      stochastic_action        │ True                \n         conv_params           │ None                \n         value_params          │ (64,)               \n        use_layer_norm         │ True                \n         buffer_size           │ 50000               \n      replay_batch_size        │ 32                  \n      prioritized_replay       │ True                \n            alpha              │ 0.6                 \n          beta_start           │ 0.4                 \n           beta_end            │ 1.0                 \n    prioritized_replay_eps     │ 1e-06               \n      grad_norm_clipping       │ 10                  \n           double_q            │ True                \n         use_dueling           │ False               \n     exploration_fraction      │ 0.1                 \n          final_eps            │ 0.1                 \n         n_timesteps           │ 100000              \n        learning_rate          │ 0.001               \n            gamma              │ 1.0                 \n        learning_start         │ 1000                \n        learn_interval         │ 1                   \ntarget_network_update_interval │ 500                 \n═══════════════════════════════╧═════════════════════\n             RUN              \n───────────────────────────────┬─────────────────────\n        log_directory          │ /mnt/slab/krypton/machine_learning/ge_dqn/2017-11-20/162048.353909-MountainCar-v0-prioritized_replay(True)\n          checkpoint           │ checkpoint.cp       \n           log_file            │ output.log          \n═══════════════════════════════╧═════════════════════\n          Reporting           \n───────────────────────────────┬─────────────────────\n     checkpoint_interval       │ 10000               \n        reward_average         │ 100                 \n        print_interval         │ 10                  \n═══════════════════════════════╧═════════════════════\n╒════════════════════╤════════════════════╕\n│      timestep      │        1999        │\n├────────────────────┼────────────────────┤\n│      episode       │         10         │\n├────────────────────┼────────────────────┤\n│    total reward    │       -200.0       │\n├────────────────────┼────────────────────┤\n│ total reward/mean  │       -200.0       │\n├────────────────────┼────────────────────┤\n│  total reward/max  │       -200.0       │\n├────────────────────┼────────────────────┤\n│time spent exploring│       82.0%        │\n├────────────────────┼────────────────────┤\n│    replay beta     │        0.41        │\n╘════════════════════╧════════════════════╛\n```\n\n```python\nfrom tf_logger import TF_Logger\n\nlogger = TF_Logger('/mnt/slab/krypton/unitest')\nlogger.log(0, some=Color(0.1, 'yellow'))\nlogger.log(1, some=Color(0.28571, 'yellow', lambda v: f\"{v * 100:.5f}%\"))\nlogger.log(2, some=Color(0.85, 'yellow', percent))\nlogger.log(3, {\"some_var/smooth\": 10}, some=Color(0.85, 'yellow', percent))\nlogger.log(4, some=Color(10, 'yellow'))\nlogger.log_histogram(4, td_error_weights=[0, 1, 2, 3, 4, 2, 3, 4, 5])\n```\n\ncolored output: (where the values are yellow)\n```log\n╒════════════════════╤════════════════════╕\n│        some        │        0.1         │\n╘════════════════════╧════════════════════╛\n╒════════════════════╤════════════════════╕\n│        some        │     28.57100%      │\n╘════════════════════╧════════════════════╛\n╒════════════════════╤════════════════════╕\n│        some        │       85.0%        │\n╘════════════════════╧════════════════════╛\n╒════════════════════╤════════════════════╕\n│  some var/smooth   │         10         │\n├────────────────────┼────────────────────┤\n│        some        │       85.0%        │\n╘════════════════════╧════════════════════╛\n```\n![logger-colored-output](./figures/logger_color_output.png)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeyang%2Ftf_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeyang%2Ftf_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeyang%2Ftf_logger/lists"}