Code Monkey home page Code Monkey logo

umap_pytorch's People

Contributors

elyxlz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

umap_pytorch's Issues

Utilizing custom CNN Modules such as umap_pytorch.model.conv_encoder

First of all, many thanks for the pytorch implementation and library! It has saved me so many headaches and is very easy to use out of the box. Looking forward to any future updates :)
My question is regarding the conv_encoder Module, or (more generally) creating a similar CNN encoder.
To your knowledge, is there currently a way to pass in a custom encoder class into a PUMAP object without making any drastic changes to the source code?
I have a custom encoder that I pass into my PUMAP object, after which I transform the input data. As you'll notice, I tried to use the conv_encoder as a template, but at the cost of making some unsavory updates like reshaping the input tensor in the forward method or setting a custom input length of the first Linear layer. I've had to make these changes to accommodate my use case.

class umap_encoder(nn.Module):
    def __init__(self, embeddings_length, n_components=20):
        super().__init__()
        self.encoder = nn.Sequential(
            nn.Conv2d(
                in_channels=1, out_channels=64, kernel_size=3, stride=2, padding=1,
            ),
            nn.Conv2d(
                in_channels=64, out_channels=128, kernel_size=3, stride=2, padding=1,
            ),
            nn.Flatten(),
            nn.Linear(embeddings_length*4, 512),
            nn.ReLU(),
            nn.Linear(512, 512),
            nn.ReLU(),
            nn.Linear(512, n_components)
        ).cuda()
    def forward(self, X):
        return self.encoder(reshape(X, (1, X.shape[0], X.shape[1])))

Here is theinstantiated PUMAP object. In this case emb.shape[1] = 384.

PUMAP(
    encoder=umap_encoder(emb.shape[1], num_components), 
    n_neighbors=15, 
    min_dist=0.0, 
    metric='cosine', 
    n_components=num_components, 
    random_state=42
)

If this is a matter of changing the order of operations, or if I need to remove/add a layer I'm happy to take any feedback. Thanks for your time

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.