Giter VIP home page Giter VIP logo

Comments (4)

ZohebAbai avatar ZohebAbai commented on May 28, 2024 1

I have tested the code for sure. The Tensorflow version gives an exact numerical answer as the Pytorch version. Code for test attached below:

from focal_frequency_loss import FocalFrequencyLoss as FFL
from tf_focal_frequency_loss import FocalFrequencyLoss as TFFL

# Pytorch
import torch

ffl = FFL(loss_weight=1.0, alpha=1.0)  # initialize nn.Module class

fake = torch.randn(4, 3, 64, 64)
real = torch.randn(4, 3, 64, 64)

pt_loss = ffl(fake, real)  # calculate focal frequency loss


# Tensorflow
import tensorflow as tf

tffl = TFFL(loss_weight=1.0, alpha=1.0)  # initialize tf.keras.layers.Layer class

fake = tf.convert_to_tensor(fake.numpy(), tf.float32)
real = tf.convert_to_tensor(real.numpy(), tf.float32)

tf_loss = tffl(fake, real)  # calculate focal frequency loss

# Check
import numpy as np
assert np.isclose(pt_loss.numpy(), tf_loss.numpy()) , "Results don't match"

I have trained a Pix2Pix model using this tensorflow implementation and it does give better results (compared to training without it), but I haven't recreated the official repo results to compare its performance.

from focal-frequency-loss.

EndlessSora avatar EndlessSora commented on May 28, 2024 1

Thanks a lot for the nice support. I have already mentioned this unofficial TensorFlow implementation in our README.

from focal-frequency-loss.

EndlessSora avatar EndlessSora commented on May 28, 2024

Thank you so much for the nice TensorFlow implementation! Have you tested the code and its performance compared with this official repo?

from focal-frequency-loss.

ZohebAbai avatar ZohebAbai commented on May 28, 2024

Thanks a lot for the support.

from focal-frequency-loss.

Related Issues (13)

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.