Code Monkey home page Code Monkey logo

Comments (3)

nicrie avatar nicrie commented on June 21, 2024 1

I've made a small tweak that eliminates at least one unnecessary computation. Feel free to push to the branch for any improvements regarding this issue.

from xeofs.

slevang avatar slevang commented on June 21, 2024

This also leads to some serious inefficiencies if we set compute=False, because we end up computing the SVD multiple times. With the current structure, it's unavoidable that we compute during the sign flip and then again when we compute the DataContainer objects. Although I wonder if this step could be moved as some postprocessing layer after whatever our first compute call is. May take some significant restructuring.

DataContainer.compute() is particularly inefficient though in this respect, because the loop will end up computing the SVD for each object we need to compute:
https://github.com/nicrie/xeofs/blob/1f38a5b818a5d5fc55720e1119e6f686aef89168/xeofs/data_container/data_container.py#L29-L36

Easily optimized with something like this, where dask.compute will optimize the task graph for all objects simultaneously:

def compute(self, verbose=False):
        computed_data = {k: v for k, v in self.items() if self._allow_compute[k]}
        if verbose:
            with ProgressBar():
                computed_data = dask.compute(computed_data)[0]
        else:
            computed_data = dask.compute(computed_data)[0]
        for k, v in computed_data.items():
            self[k] = v

from xeofs.

nicrie avatar nicrie commented on June 21, 2024

Indeed, off the top of my head, just some additional thoughts:

In the Sanitizer

  • make the sanity check optional for those cases where we know/expect to not have any NaNs (cross-ref #83 )
  • self.is_valid_sample is computed twice, once in fit and then again in transform. It is sufficient to compute in transform only and then assign it self.is_valid_sample if it does not exist yet

https://github.com/nicrie/xeofs/blob/1f38a5b818a5d5fc55720e1119e6f686aef89168/xeofs/preprocessing/sanitizer.py#L74

https://github.com/nicrie/xeofs/blob/1f38a5b818a5d5fc55720e1119e6f686aef89168/xeofs/preprocessing/sanitizer.py#L95-L98

  • use dask.compute() to avoid redundant computations for self.is_valid_feature and self.is_valid_sample not sure if actually feasible since we can compute valid samples only when we know the valid features

I hoped that in many cases the decomposition result would fit into memory (say if you only need 10 modes). In that case compute=True is already not too bad. Apart from the Sanitizer check there shouldn't be any redundant computations.

from xeofs.

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.