{"id":17222774,"url":"https://github.com/cheind/tf-matplotlib","last_synced_at":"2025-04-14T00:19:13.176Z","repository":{"id":57485465,"uuid":"126341674","full_name":"cheind/tf-matplotlib","owner":"cheind","description":"Seamlessly integrate matplotlib figures as tensorflow summaries.","archived":false,"fork":false,"pushed_at":"2018-12-17T22:54:25.000Z","size":2967,"stargazers_count":119,"open_issues_count":2,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-27T14:21:26.265Z","etag":null,"topics":["blittable","confusion-matrix","matplotlib","tensorboard","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheind.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-22T13:45:15.000Z","updated_at":"2023-06-04T06:27:46.000Z","dependencies_parsed_at":"2022-09-10T05:00:49.871Z","dependency_job_id":null,"html_url":"https://github.com/cheind/tf-matplotlib","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Ftf-matplotlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Ftf-matplotlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Ftf-matplotlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Ftf-matplotlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheind","download_url":"https://codeload.github.com/cheind/tf-matplotlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799984,"owners_count":21163404,"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":["blittable","confusion-matrix","matplotlib","tensorboard","tensorflow"],"created_at":"2024-10-15T04:06:19.856Z","updated_at":"2025-04-14T00:19:13.139Z","avatar_url":"https://github.com/cheind.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### **tf-matplotlib** - seamless integration of matplotlib figures into TensorFlow summaries\n\n**tf-matplotlib** renders your everyday matplotlib figures tinside TensorFlow's Tensorboard visualization interface. The library\n - takes care of evaluating input tensors prior to plotting, \n - avoids matplotlib threading issues,\n - support multiple figures and,\n - provides blitting for runtime critical plotting. \n \nThe following TensorFlow summary is generated by [sgd.py](tfmpl/samples/sgd.py). It plots the progress of gradient descent optimizers on a test surface. To avoid redrawing the test surface, it makes use of blitting. See [usage](#usage) below for a more introductory example.\n\n![](etc/sgd.gif)\n\n### Installation\n\n```\npip install tfmpl\n```\n\nRequirements\n - Python 3.5/3.6\n - TensorFlow 1.x\n - matplotlib 2.2.0\n\n### Build status\n\n|Branch|Linux|Windows|\n|------|------|------|\n|master|![](https://travis-ci.org/cheind/tf-matplotlib.svg?branch=master)| ![](https://ci.appveyor.com/api/projects/status/reo8nucumqhb93q5/branch/master?svg=true) |\n|develop|![](https://travis-ci.org/cheind/tf-matplotlib.svg?branch=master)|![](https://ci.appveyor.com/api/projects/status/reo8nucumqhb93q5/branch/develop?svg=true)|\n\n### Usage\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n\nBelow are the relevant snippets to render a simple scatter plot. See [scatter.py](tfmpl/samples/scatter.py) for the complete self-contained example.\n\n```python\nimport tensorflow as tf\nimport numpy as np\n\nimport tfmpl\n\n@tfmpl.figure_tensor\ndef draw_scatter(scaled, colors): \n    '''Draw scatter plots. One for each color.'''  \n    figs = tfmpl.create_figures(len(colors), figsize=(4,4))\n    for idx, f in enumerate(figs):\n        ax = f.add_subplot(111)\n        ax.axis('off')\n        ax.scatter(scaled[:, 0], scaled[:, 1], c=colors[idx])\n        f.tight_layout()\n\n    return figs\n\nwith tf.Session(graph=tf.Graph()) as sess:\n\n    # A point cloud that can be scaled by the user\n    points = tf.constant(\n        np.random.normal(loc=0.0, scale=1.0, size=(100, 2)).astype(np.float32)\n    )\n    scale = tf.placeholder(tf.float32)        \n    scaled = points*scale\n\n    # Note, `scaled` above is a tensor. Its being passed `draw_scatter` below. \n    # However, when `draw_scatter` is invoked, the tensor will be evaluated and a\n    # numpy array representing its content is provided.   \n    image_tensor = draw_scatter(scaled, ['r', 'g'])\n    image_summary = tf.summary.image('scatter', image_tensor)      \n    all_summaries = tf.summary.merge_all() \n    \n    writer = tf.summary.FileWriter('log', sess.graph)\n    summary = sess.run(all_summaries, feed_dict={scale: 2.})\n    writer.add_summary(summary, global_step=0)\n```\n\n![](etc/scatter.png)\n\n### Draw utilities\n\nWhen doing classification, a common task is to generate a confusion matrix. **tf-matplotlib** provides `tfmpl.draw.confusion_matrix` to quickly generate such a plot from labels and predictions. The following plot shows classification training progress on the MNIST classification task. Full sample code is provided in [mnist.py](tfmpl/samples/mnist.py).\n\n![](etc/cm.gif)\n\n### License\n\n```\nMIT License\n\nCopyright (c) 2018 Christoph Heindl\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Ftf-matplotlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheind%2Ftf-matplotlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Ftf-matplotlib/lists"}