Comments (11)
normalize_tensor doesn't take the norm, it normalizes the tensor. I think the implementation matches the paper.
from perceptualsimilarity.
Hello,
I still have issues understanding how the implementation matches the paper formula
lets say we have the following example:
a = np.array([0.1, 0.4, 0.2])
b = np.array([0.3, 0.5, 0.6])
w = np.array([1,1,1])
eps = 1e-10
we normalize the two inputs a and b:
a_n = a / (np.sqrt(np.sum(a**2)) + eps)
b_n = b / (np.sqrt(np.sum(b**2)) + eps)
now from the paper formula i would expect the following computation:
np.dot(w, (a_n - b_n)) ** 2
0.021256129990661603
in the implementation its computed like this:
np.sum(np.subtract(a_n, b_n)**2)
0.1742581415905922
which would be equivalent to np.dot(w, (a_n - b_n) ** 2)
(for w_l = 1∀l)
shouldn't it be:
np.sum(np.subtract(a_n, b_n))**2
0.021256129990661603
or did I miss something?
Thanks in advance!
from perceptualsimilarity.
Each element needs to be squared first (see how p-norms are calculated)
from perceptualsimilarity.
Thanks a lot for the reply!
Still feel like the formula in the paper is not matching the implementation since in the formula the norm is computed after the dot product which already sums up the difference (with w_l = 1∀l)
Nevertheless thanks a lot for clarifying the implementation, it is clear to me now.
Best Regards
from perceptualsimilarity.
Inside the || || is a vector, not a scalar. The symbol does not mean dot product
from perceptualsimilarity.
Sorry, somehow missed the reply. Thanks!
from perceptualsimilarity.
Hi, thank you for your amazing work, but I also find the code a bit different from the paper:
In paper you have L2(w*(y_1-y_2)), but in the code you have dot(w, L2((y_1-y_2))).
from perceptualsimilarity.
Yes, the w
in the code is actually w^2
in the paper.
from perceptualsimilarity.
Thank you so much for your reply. May I ask another question?
I am trying to re-train with your code, I get most of the weight of w == 0, because of the clamping.
But in the public weights, you get most of w (70%-90%) < 0.1 but >0 as you showed in your paper.
Could you let me know whether the public weights were trained with published code, that w is not squared and clamped?
from perceptualsimilarity.
Hmm, the weights should match the code. Many of the weights are 0 in the official model as well (see Fig 10 in the paper: https://arxiv.org/pdf/1801.03924.pdf), depending on the variant
from perceptualsimilarity.
Yes. Thank you. I checked the official model, most weights are close to 0 (<0.1) but not actually 0. Mine re-trained model has most weights equal to 0. I will debug more. Thanks!
from perceptualsimilarity.
Related Issues (20)
- How we can use PerceptualSimilarity loss function for images with different sizes HOT 2
- AttributeError: module 'lpips' has no attribute 'normalize_tensor'
- Why do I get different results when running the same data multiple times? HOT 3
- Distortions HOT 1
- Two warnings from Torchvision
- Has anybody applied this metrics to libtorch(c/c++)?
- torch.device("cuda:0")? HOT 1
- How to ignore some pixels when calculating the loss? HOT 1
- Update pip package
- normalization in BGR HOT 3
- Distance measure after training
- RuntimeError: Function 'SqrtBackward0' returned nan values in its 0th output HOT 4
- How to expand the use?
- Update conda package
- how can I wget the JND Dataset, the old URL was unavailable? HOT 4
- Can be used for 3D data ? HOT 2
- How to apply this function to 1channel image? HOT 4
- Using LPIPS with AMP
- How do I turn off the screen spam? HOT 1
- Is there any labels of distortion types for the BAPPS dataaset?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perceptualsimilarity.