Package: graphWriter
GraphWriterGraphWriter is a robust, interactive, and visually appealing wrapper for TensorBoard's SummaryWriter, designed to provide real-time insights into your machine learning model's performance right in your terminal. It uses the Rich library to render elegant visualizations, progress bars, and logs, thus turning your mundane terminal into a vibrant dashboard.FeaturesReal-time scalar plots for training and testing metrics.Progress bars for iterable processes such as epochs and batches.Customizable console print function to log insights in a structured manner.Grouping of scalars based on prefixes for organized visualization.Colorful and lively terminal output, making the model training process more interactive and insightful.InstallationThe project requirestorch,rich, andasciichartpylibraries to be installed in your python environment.pipinstallgraphWriterExampleYou can run the example script to see the GraphWriter in action.python-mgraphWriter.graphWriterUsagefromtorch.utils.tensorboardimportSummaryWriterfromgraphWriterimportGraphWriterimportmathimportrandom# Initialize Tensorboard SummaryWriterwriter=SummaryWriter()# Create an instance of GraphWritergraph_writer=GraphWriter(writer)# Simulate a training and testing processforeingraph_writer.track(range(100),description="epochs"):fortingraph_writer.track(range(100),description="training"):# Simulated metricstrain_loss=3*math.exp(-0.1*e+0.1*random.gauss(0,1))train_acc=100-20*math.exp(-1.5*e/30)-random.randrange(0,90)/(e+1)# Log metricsgraph_writer.add_scalar('Train/Loss',train_loss,global_step=t+e*100)graph_writer.add_scalar('Train/Acc',train_acc,global_step=t+e*100)fortingraph_writer.track(range(100),description="testing"):# Simulated metricstest_loss=2*math.exp(-0.1*e+0.2*random.gauss(0,1))test_acc=100-20*math.exp(-2.0*e/30)-random.randrange(0,90)/(e+1)# Log metricsgraph_writer.add_scalar('Test/Loss',test_loss,global_step=t+e*100)graph_writer.add_scalar('Test/Acc',test_acc,global_step=t+e*100)graph_writer.add_scalar('Epochs',e,global_step=e)graph_writer.print(f"Epoch [green]{e}[/green] completed!")# close the writerwriter.close()TheGraphWriterclass is initialized with aSummaryWriterobject, along with optional arguments for setting the maximum number of lines for print statements and progress bars. Theadd_scalarmethod is used to log scalar values to TensorBoard, and thetrackmethod is utilized to create progress bars for iterable processes.MethodsHere's a brief overview of the primary methods available in theGraphWriterclass:add_scalar(tag, scalar_value, global_step=None, display=True): Logs a scalar value to TensorBoard and updates the scalar panel.print(*args, **kwargs): A custom print function to display text in the print layout.track(iterable, description="Processing..."): Yields items from an iterable and updates a progress bar.update_scalars(tag): Updates the scalar panels with new data.group_scalars_by_prefix(): Groups scalar layouts by their prefix for organized visualization.ContributingContributions are welcome! Feel free to open an issue or submit a pull request.LicenseMITThis README provides a comprehensive overview of the GraphWriter project, its features, installation steps, usage examples, available methods, and contribution guidelines.