Giter VIP home page Giter VIP logo

Comments (14)

mikkokotila avatar mikkokotila commented on May 21, 2024 2

Ok great, I will add that. I'm using it in another project, and I think it should be fairly simple. I also have a working implementation of live updating plot that shows progress per epoch so will include both in the same update. It seems the progress bar should be a parameter so it can be turned off (maybe on by default?).

from talos.

matthewcarbone avatar matthewcarbone commented on May 21, 2024 1

Sorry missed the question when I read your comment the first time. Yes I think it is standard to have a toggle for it. There must be an easy way to do that with tqdm if that's what you're using. Its important that you mentioned this since some notebooks (Google Colab...) do not play nicely with tqdm!

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024 1

Tried this and unfortunately it's going to be a little complicated.

The way the loop is handled now:

        if self.round_limit is not None:
            for i in range(self.round_limit):
                self._null = self._run()
        else:
            while len(self.param_log) != 0:
                self._null = self._run()

Out of these two the more common case is the else where round_limit is not set (second case). The first case is very simple and a standard use-case for tqdm. The second case is problematic in the sense that if a reduction method is applied, then the self.param_log keeps becoming smaller faster than 1 per iteration. Not to say that this is not possible to implement, but is not going to be as simple as I hoped. The question that would need to be answered is related with how to handle the case where a reducer is used; for example you might have 20 hours to start with, and then it jumps down to 10, then to 2, and so on...and in the process it might not also be so accurate as there is a great degree of variety depending on the hyperparameters.

from talos.

matthewcarbone avatar matthewcarbone commented on May 21, 2024 1

I think I understand. There should be ways to manually update the progress bar. Here's an example (I didn't test it yet).

I can look into this in more detail sometime later as well!

Edit: also, I think just having more or less an indicator of the amount of progress Scan has made is desirable, even independent of the estimated time until the process finishes. (I just like to know something is happening in the background!).

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024 1

@x94carbone re 'Edit' > great. I was thinking like that as well. I think there are two sides to this; something that serves the purpose of terminal and notebook use, and then secondarily for the notebook use only. For notebook it seems that a live updating matplotlib plot is an idea situation as you can also see epoch level updates (and get an idea of how the training takes place which can be really valuable especially early in the process or an automated reduction/optimization method is used). How about a very simple x out of xxx rounds left for the universal case?

from talos.

matthewcarbone avatar matthewcarbone commented on May 21, 2024 1

@mikkokotila right I totally agree. There's got to be an easy way for the program to detect whether or not its running in a notebook or not. Regardless, since there are some notebooks that don't play nice with these progress bars, we should implement some default behavior first. Something like what you suggested should work great! Particularly, maybe something that constantly overwrites the first output line so we don't overwhelm the user with a ton of output.

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024 1

@x94carbone what do you think, can we assume that the user is not going to want to have verbose for model.fit on anything except 0? If we can assume that, we can detect the os, and then according to the os we use a system clear command (windows cls and otherwise clear). Here we just accept that whatever have been shown on the terminal / notebook will be cleared. What do you think?

from talos.

matthewcarbone avatar matthewcarbone commented on May 21, 2024 1

We might not even have to make it that complicated actually- I may have been overthinking it. We could implement three options and let the user choose for themselves. 0 for silent running, 1 for progress bar and 2 for raw text output. Maybe that’s a better starting place than detecting the os or if the user is in a notebook. Then once we have that working we can go from there. What do you think?

from talos.

matthewcarbone avatar matthewcarbone commented on May 21, 2024 1

I have another idea actually. We don't need a progress bar, we can do this with the Python 3 print function if we're clever. Backwards compatible via from __future__ import print_function, I think. I will give this a shot at some point soon.

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024 1

I've added tqdm which is on by default. Together with some notable changes, you can find it in dev-mikko, and hopefully tomorrow in daily-dev as well (will have to do more testing, and also add some unit tests).

from talos.

Geekgurus avatar Geekgurus commented on May 21, 2024 1

This Should Help.
Example Solution From My Experience

Configuration
If #tqdm is not already installed, install it with #pip.

pip install #tqdm
Suppose the flyer in question is called flyer, an instance of the class Flyer. Find where flyer is defined in your IPython profile. Something like:

flyer = Flyer(some_arguments)
We can subclass Flyer, customizing its collect method to incorporate a progress bar.

class FlyerWithProgressBar(Flyer):

def collect(self):
    yield from tqdm(super().collect())

flyer = FlyerWithProgressBar(some_arguments

If you have some way of knowing in advance how many data points will be yielded by collect, you can provide that information to tqdm to make it more informative. (It can predict the time remaining, for example.) Suppose we have a flyer that always produces 100 data points. The class should be defined like:

class FlyerWithProgressBar(Flyer):

def collect(self):
    yield from tqdm(super().collect()

Or, add an attribute that can be updated interactively: πŸ‘»

from talos.

Geekgurus avatar Geekgurus commented on May 21, 2024 1

And finally it goes this way 😳

interactively:

class FlyerWithProgressBar(Flyer):

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)  # pass arguments to Flyer
    self.total = 100

def collect(self):
    yield from tqdm(super().collect(), total=self.total)

Here is a demo of FlyerWithProgressBar.

In [1]: from bluesky.plans import fly

In [2]: flyer = FlyerWithProgressBar()

In [3]: plan = fly([flyer])

In [4]: RE(plan)
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 100/100 [00:01<00:00, 92.35it/s]
Out[4]: ['3acf0eb7-96bf-4c09-b813-e715dab

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024

That would be good if we could do it very simply! :)

from talos.

mikkokotila avatar mikkokotila commented on May 21, 2024

Progress bar had been added some time ago and now available in master as well as pip so closing here.

from talos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.