Coder Social home page Coder Social logo

Multiple backends support about torchstain HOT 7 CLOSED

eidoslab avatar eidoslab commented on August 18, 2024
Multiple backends support

from torchstain.

Comments (7)

carloalbertobarbano avatar carloalbertobarbano commented on August 18, 2024 1

Yes I think it's on the right track. Probably the base classes such as HENormalizeer, MacenkoNormalizer etc should be common to both modules, maybe in a base module.

from torchstain.

carloalbertobarbano avatar carloalbertobarbano commented on August 18, 2024 1

I think the entire torchstain library could be installed, and then the user will be able to specify backend="torch" or backend="tensorflow" when instantiating a normalizer.

It might event be useful to have a global method such as torchstain.set_backend() to set a default backend instead.

The imports in torchstain should be done based on the backend specified by the user (by doing "pip install torchstain[tf]" the user is just saying that the pytorch dependency is not necessary and won't be installed).

from torchstain.

carloalbertobarbano avatar carloalbertobarbano commented on August 18, 2024

The idea of having separate modules as in your branch is good, as we also need to port the different utilities from pytorch to tf. I tried to setup a project (you have write access to it) so that we can keep track of all the features

from torchstain.

andreped avatar andreped commented on August 18, 2024

I've gotten a bit further now. It is not finished yet, but do you approve of the design, @carloalbertobarbano?
https://github.com/andreped/torchstain/tree/backends/torchstain

Need to get the pip install torchstain[backend] working somehow as well. As well as, verifying that you are able to install torchstain with a specific backend, without needing the other; if you install with torch, you do not install tf at all, and vice versa.

However, there are some duplicate code between the subpackages, so there are probably improvements to be made.

from torchstain.

andreped avatar andreped commented on August 18, 2024

Good idea. The problem is that when I install, I wish to install some specific subpackage, without the other, so it was easier to include the base both places, but I agree. Having a base subpackage is more scalable.

from torchstain.

andreped avatar andreped commented on August 18, 2024

Ok, I think I managed to get it properly working now. It was a lot more annoying to do than first anticipated, due to packages/modules, dependencies, and imports operate in Python. At least all the CI tests works fine, and you can use the tool with torch without needing tensorflow, and vice versa. Same usage as before. Just choose which backend to use to the MacenkoNormalizer class. I also made a separate base subpackage as discussed.

The last thing that remains is to be able to simplify the imports, which I believe you might have an idea of how to do. I didn't find a simple way, probably some simple __init__.py magic needed :P

Currently, for using the MacenkoNormalizer, you need to run: torchstain.base.normalizers.macenko_normalizer.MacenkoNormalizer(), but ideally you should just run: torchstain.MacenkoNormalizer().

For debugging, please, see my current implementation:
https://github.com/andreped/torchstain/tree/backends/torchstain

I will make a PR and you can make comments and reviews there.

from torchstain.

carloalbertobarbano avatar carloalbertobarbano commented on August 18, 2024

Resolved in #16

from torchstain.

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.