leymir / hyperbolic-image-embeddings Goto Github PK
View Code? Open in Web Editor NEWSupplementary code for the paper "Hyperbolic Image Embeddings".
License: MIT License
Supplementary code for the paper "Hyperbolic Image Embeddings".
License: MIT License
I have tried to reproduce your hyperbolicity experiments with the cifar10 dataset, using the code in delta.py. I have stumbled across a potential error. In the paper you calculate the relative Hyperbolicity of a dataset by doing the following calculation:
δrel(X) = 2δ(X) / diam(X)
However, in the delta.py δ(X) is not multiplied by 2, giving incorrect results:
delta_rel = delta_hyp(distmat) / diam
When I multiply by 2 it seems to work and I can reproduce the cifar10 hyperbolicity score:
delta_rel = (2 * delta_hyp(distmat)) / diam
Is this change correct?
I followed the instruction to run this code, but I can't achieve the accuracy as reported in the paper. As shown in instructions, python train_protonet.py --gpu 0 --hyperbolic --dataset MiniImageNet --dim 1024 --lr 0.001 --c 0.05 --gamma 0.2 --step_size 10
was used at my experiments, the accuracy can only achieve 43.92%, it is a lot behind 51.57% that shown in the paper.
Thanks for sharing your great work! Since the hyperbolic neural network is pretty well-defined and I imagine building convolution layers won't be too difficult (correct me if I'm wrong), I was wondering if you guys experimented with building a fully hyperbolic CNN? Can you please share your thoughts regarding that?
in
https://github.com/KhrulkovV/hyperbolic-image-embeddings/blob/master/hyptorch/pmath.py#L426
you use
https://github.com/KhrulkovV/hyperbolic-image-embeddings/blob/master/hyptorch/pmath.py#L106
but should
def lorenz_factor(x, *, c=1.0, dim=-1, keepdim=False):
"""
Parameters
----------
x : tensor
point on Klein disk
c : float
negative curvature
dim : int
dimension to calculate Lorenz factor
keepdim : bool
retain the last dim? (default: false)
Returns
-------
tensor
Lorenz factor
"""
return 1 / torch.sqrt(1 - c * x.pow(2).sum(dim=dim, keepdim=keepdim))
Also the comment on
And the point HypAvg(x, y)
should probably be HypAvg(x, y, z)
. HypAvg(x, y)
should correspond to pmath.geodesic(.5, x, y)
Hi Valentin,
Thanks for your excellent work and codes. I am very interested in the hyperbolic space, and would like to know how to visualize feature embeddings in the hyperbolic space (as shown in the Fig. 1 of your paper). I didn't find the codes for the feature visualization. Can you please release the codes?
Thanks a lot.
Xiaohan
Thanks a lot for sharing your repo. I am new to hyperbolic neural networks, and I learned a lot from your repo.
While i am reading the code of examples/mnist.py, i am curious about why ToPoincare
is only applied for x which is calculated by a neural network, whereas, ToPoincare
is not applied for p_val in HyperbolicMLR.
consider that they are both need a expmap0
to map them from
Hi. This is a very interesting and inspiring work. I just use your code to my dataset for computing feature distance. I found that all the values of '_mobius_add(-x, y, c).norm(dim=-1, p=2, keepdim=keepdim' of the line 207 of './hyptorch/pmath.py' tend to be 1. Did you meet the same issue like this or have any suggestions? Thanks.
Thanks a lot for sharing the repo! In your paper, you presented a nice visualization showing the distribution of hyperbolic distances of embeddings (MNIST vs. Omniglot). I'm wondering from which stage did you obtain the embeddings to calculate those distances?
My guess is the output of the line below. Can you please confirm this is indeed the case?
Thanks!
when i run the mnist example i get the loss is nan, is the ToPoincare cause result?
Hello authors,
Sorry to add another issue about this -- I've read everything in the existing (closed) issues, but I'm still having problems reproducing the results.
Here are is what I ran and what I got for CUB 1s5w (conv4):
# CUB 1s5w (conv4) 0.6402 +- 0.002
python train_protonet.py \
--dataset CUB \
--shot 1 \
--lr 0.001 \
--step 50 \
--gamma 0.8 \
--c 0.05 \
--model convnet \
--hyperbolic \
--not-riemannian \
--dim 1600
### OUTPUT ###
batch 9998: 62.48(49.33)
batch 9999: 62.47(54.67)
batch 10000: 62.47(54.67)
Val Best Acc 0.6809, Test Acc 0.6247
Test Acc 0.6247 + 0.0024
Here are is what I ran and what I got for MiniImageNet 1s5w (conv4):
# MiniImageNet 1s5w (conv4) 0.5443 +- 0.002
python train_protonet.py \
--dataset MiniImageNet \
--way 30 \
--shot 1 \
--lr 0.005 \
--step 80 \
--gamma 0.5 \
--c 0.01 \
--model convnet \
--hyperbolic \
--not-riemannian \
--dim 1600
### OUTPUT ###
batch 9998: 52.15(44.00)
batch 9999: 52.15(60.00)
batch 10000: 52.15(42.67)
Val Best Acc 0.5362, Test Acc 0.5215
Test Acc 0.5215 + 0.0020
Hi authors, many thanks for your released code, it helps me better to understand your excellent work. A question is that reported results in your paper on the MiniImagenet dataset 1-shot 5-way using 4 Cov is 54.43, while I got less than 40 using your code. Maybe there are some mistakes in my operations, could you tell me some crucial steps when carrying out this code? Thanks very much!
Yes, it is necessary.
Hi! Excellent work! Thank you for releasing the codebase. I wanted to know how to calculate the hyperbolicity of the image datasets (section 3.1 in the paper). I can see a delta.py file in the codebase but no instructions on how to use this. Any help would be appreciated. Thanks in advance!
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.