GitHub - fastai/fast_progress: Simple and flexible progress bar for Jupyter Note...
source link: https://github.com/fastai/fast_progress
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
fast_progress
A fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai.
Copyright 2017 onwards, fast.ai. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.
Usage
Here is a simple example. Each bar takes a generator as a main argument, and we can speicify the second bar is nested with the first by adding the argument parent=mb. We can then
- add a comment in the first bar by changing the value of mb.first_bar.comment
- add a comment in the first bar by changing the value of mb.child.comment
- write a line between the two bars with mb.write('message')
from fast_progress import master_bar, progress_bar from time import sleep mb = master_bar(range(10)) for i in mb: for j in progress_bar(range(100), parent=mb): sleep(0.01) mb.child.comment = f'second bar stat' mb.first_bar.comment = f'first bar stat' mb.write(f'Finished loop {i}.') #mb.update_graph(graphs, x_bounds, y_bounds)
To add a graph that get plots as the training goes, just use the command mb.update_graphs. It will create the figure on its first use. Arguments are:
- graphs: a list of graphs to be plotted (each of the form [x,y])
- x_bounds: the min and max values of the x axis (if None, it will those given by the graphs)
- y_bounds: the min and max values of the y axis (if None, it will those given by the graphs)
Note that it's best to specify x_bounds and _bounds otherwise the box will change as the loop progresses.
Additionally, we can give the label of each graph via the command mb.names (should have as many elements as the graphs argument).
import numpy as np mb = master_bar(range(10)) mb.names = ['cos', 'sin'] for i in mb: for j in progress_bar(range(100), parent=mb): if j%10 == 0: k = 100 * i + j x = np.arange(0, 2*k*np.pi/1000, 0.01) y1, y2 = np.cos(x), np.sin(x) graphs = [[x,y1], [x,y2]] x_bounds = [0, 2*np.pi] y_bounds = [-1,1] mb.update_graph(graphs, x_bounds, y_bounds) mb.child.comment = f'second bar stat' mb.first_bar.comment = f'first bar stat' mb.write(f'Finished loop {i}.')
Here is the rendering in console:
Recommend
-
344
Welcome to fastai fastai simplifies training fast and accurate neural nets using modern best practices Important: This documentation covers fastai v2, which is a from-scratch rewrite of f...
-
55
Note from Jeremy : Want to learn more? Listen to me discuss fastai with Sam Charrington in this in-depth inte...
-
43
-
41
README.md course-v3 The 3rd edition of course.fast.ai. See the nbs folder for the notebooks.
-
58
Figure 1: Segmentation results Image segmen...
-
36
When I first started learning Machine Learning and deep learning, It took me forever to learn how to build an image classifier, I took all machine lear...
-
16
Jeremy’s notes on fastai coding style This is a brief discussion of fastai’s coding style, which is loosely informed by (a much diluted version of) the ideas developed over the last 60 continuous years of develo...
-
27
本文为fastai官方教程编译版本。若有错误,欢迎指正。 总目录: 查看数据:本节为初级教程,介绍怎样快速的查看你的数据和模型预测结果。 推理学习器(Inference Lea...
-
29
Fastai is now using Python and PyTorch to be productive and hackable. A recent paper published by fastai states that the use of Python and PyTorch is helping them to be quick and clear. ...
-
2
Adicionando kernels do C# e F# no Jupyter Notebook/Lab. (#csharp #fsharp #dotnet #jupyter) Posted on
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK