GithubHelp home page GithubHelp logo

rafizunaed / domain_agnostic_content_aware_style_invariant Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 5.04 MB

Learning to Generalize towards Unseen Domains via a Content-Aware Style Invariant Framework for Disease Detection from Chest X-rays

Home Page: https://arxiv.org/abs/2302.13991

brax chest-xray-images chest-xrays chexpert chexpert-dataset consistency-regularization domain-adaptation domain-generalization mimic-cxr neural-style-transfer

domain_agnostic_content_aware_style_invariant's People

Contributors

rafizunaed avatar

Watchers

 avatar

Forkers

nirvanesque

domain_agnostic_content_aware_style_invariant's Issues

Question regarding the Global Feature Enhance loss

Dear @rafizunaed ,

Thank you very much for making your code available and for you extremely insightful work on domain adaptation applied to CXRs.
I have read your publication with great interest and I have a question regarding the "Global Feature Enhancer Loss".

My understanding is that if the feature matrices are L2 normalized, the diagonal of the resulting gram matrices will always be the identity vector and therefore the GFE loss would always be 0. I must be missing something there but even when trying on some random feature tensors with following code:

def generate_gram_matrix(y):
    (b, ch, h, w) = y.size()
    features = y.view(b, ch, w * h)
    features = nn.functional.normalize(features, dim=2, eps=1e-7)
    features_t = features.transpose(1, 2)
    gram_matrix = features.bmm(features_t)
    return gram_matrix

def get_gfe_loss(x):
    gfm = x.clone()
    criterion_mse = torch.nn.MSELoss()
    gm = generate_gram_matrix(gfm)  
    scores = torch.diagonal(gm, offset=0, dim1=-2, dim2=-1)
    gt = torch.ones_like(scores)
    gfe_loss = criterion_mse(scores, gt)
    return gfe_loss

M = torch.randn((4, 12, 32, 32))
get_gfe_loss(torch.FloatTensor(M))

I always get loss of the order of 1e-13, therefore I have trouble understanding how this loss can contribute to the training.

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.