Skip to content
New issue

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

h1loss output sum, fix for issue #103 #160

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

itskobold
Copy link

h1loss output is summed to produce a scalar, training would previously break if number of output channels > 1

#103

h1loss output is summed to produce a scalar, training would previously break if number of output channels > 1
@kovachki
Copy link
Collaborator

kovachki commented Jun 23, 2023

For the loss to produce a scalar, the channel dimension must be added to the reduce_dims otherwise it will only reduce over the first dimension (this is the default behavior). Here is a 2d example:

loss = H1Loss(d=2, reduce_dims=[0,1])
x = torch.randn(5,10,128,128)
y = torch.randn(5,10,128,128)
loss(x,y)

This will be scalar.

It is done this way, so that the user has more control over what to do with each channel, for example, weighting each channel differently in your loss function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants