Giter Site home page Giter Site logo

Comments (11)

richzhang avatar richzhang commented on May 21, 2024

normalize_tensor doesn't take the norm, it normalizes the tensor. I think the implementation matches the paper.

from perceptualsimilarity.

aweinmann avatar aweinmann commented on May 21, 2024

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.

richzhang avatar richzhang commented on May 21, 2024

Each element needs to be squared first (see how p-norms are calculated)

from perceptualsimilarity.

aweinmann avatar aweinmann commented on May 21, 2024

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)
image

Nevertheless thanks a lot for clarifying the implementation, it is clear to me now.
Best Regards

from perceptualsimilarity.

richzhang avatar richzhang commented on May 21, 2024

Inside the || || is a vector, not a scalar. The symbol does not mean dot product

from perceptualsimilarity.

aweinmann avatar aweinmann commented on May 21, 2024

Sorry, somehow missed the reply. Thanks!

from perceptualsimilarity.

fukka avatar fukka commented on May 21, 2024

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.

richzhang avatar richzhang commented on May 21, 2024

Yes, the w in the code is actually w^2 in the paper.

from perceptualsimilarity.

fukka avatar fukka commented on May 21, 2024

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.

richzhang avatar richzhang commented on May 21, 2024

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.

fukka avatar fukka commented on May 21, 2024

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)

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.