Giter Site home page Giter Site logo

Split up layers/base.py about lasagne HOT 9 CLOSED

lasagne avatar lasagne commented on May 11, 2024
Split up layers/base.py

from lasagne.

Comments (9)

benanne avatar benanne commented on May 11, 2024

Looks good to me. I would call the first ? 'dense.py' and the second one 'shape.py' or something. Since these names are not really going to be exposed to the user, they're not really that crucial to get 'right' imo. Short is good :)

On that note, we should probably still make a distinction between the 'base' set of layers, that are available in the nn.layers namespace, and the more specialized stuff that is only accessible through the submodules (like nn.layers.cuda_convnet, nn.layers.corrmm).

I believe all the layers you listed are probably important enough to live in the main namespace, but we'll have to keep this in mind and make a decision when we add in the recurrent layers for example.

from lasagne.

craffel avatar craffel commented on May 11, 2024

I think splitting up base.py is definitely a good idea, but I'd propose that we give access to all of the layer classes straight from nntools.layers (e.g. DropoutLayer would be nntools.layers.DropoutLayer instead of nntools.layers.noise.DropoutLayer) - I don't think there will be any namespace conflicts (e.g. something in some layer submodule which is not in another), and I think it will save a lot of typing. I think this is what you just proposed @benanne; I guess what I'm saying is I think all layers are probably important enough to live in the main namespace.

from lasagne.

benanne avatar benanne commented on May 11, 2024

Yep, that's the idea. But for specialized stuff like the cuda_convnet and cormm layers, I don't think it's necessary. Are you saying you think these should also be available in the main namespace?

from lasagne.

craffel avatar craffel commented on May 11, 2024

I think that as long as there aren't any namespace conflicts (e.g. a layer with the same name in cuda_convnet and conv), we may as well put them all in the same namespace.

from lasagne.

benanne avatar benanne commented on May 11, 2024

I was thinking about doing this quickly, but clearly there are a lot of dependencies between future submodules. How should these be handled?

It seems cleanest to just import those submodules where necessary and use them directly. But this will make the code a bit harder to read, because it is less like 'normal' code that a user would write (i.e. a user would write layers.DenseLayer, or just DenseLayer, but never dense.DenseLayer).

The alternative is to import * the necessary submodules (since that is what happens in __init__.py anyway).

What's the best option? We should probably pick one of these and do that consistently across the library.

from lasagne.

f0k avatar f0k commented on May 11, 2024

I think the best option is yet another way: Importing just the names that are needed, to be explicit about the dependencies. E.g., if the recurrence module depends on dense.DenseLayer, it should do from .dense import DenseLayer. This way the code still reads like 'normal' code, as you called it, and we avoid the namespace mess created by import *.

from lasagne.

benanne avatar benanne commented on May 11, 2024

Yes! Let's do that :)

from lasagne.

benanne avatar benanne commented on May 11, 2024

I'll try to sort this out today.

from lasagne.

benanne avatar benanne commented on May 11, 2024

This was done in #81.

from lasagne.

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.