We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi @gnobitab , I implemented feature loss by myself, however, it did not work properly. Could you provide some comments for my pseudo code?
import torch import torch.nn.functional as F def get_feature_weight(S): def _feature_func(x): feature = feature_extractor(x) # shape [batch_size, feature_dim, H, W] feature = feature.sum(dim=(0, 2, 3)) return feature # shape [feature_dim] S = S.requires_grad_(True) # shape [batch_size, dim, H, W] w = torch.autograd.functional.jacobian(_feature_func, S) # shape [feature_dim, batch_size, dim, H, W] return w.transpose(0, 1).detach() # shape [batch_size, feature_dim, dim, H, W] w = get_feature_weight(z_t) w_target = torch.einsum('bdchw,bchw->bdhw', w, target) w_pred = torch.einsum('bdchw,bchw->bdhw', w, pred) loss = F.mse_loss(target, pred)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi @gnobitab , I implemented feature loss by myself, however, it did not work properly.
Could you provide some comments for my pseudo code?
The text was updated successfully, but these errors were encountered: