elyxlz / umap_pytorch Goto Github PK
View Code? Open in Web Editor NEWPytorch port for Parametric Umap
License: MIT License
Pytorch port for Parametric Umap
License: MIT License
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.