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

why did the loss function define ? #1

Open
NenerLiu opened this issue Oct 25, 2023 · 0 comments
Open

why did the loss function define ? #1

NenerLiu opened this issue Oct 25, 2023 · 0 comments

Comments

@NenerLiu
Copy link

def tv_loss_plus_var_loss(y_true, y_pred):
"""
Define the composite loss function that includes total variation of errors
loss and variance of errors loss
"""
# total variation loss
y_x = y_true[:, 1:256, :, :] - y_true[:, 0:255, :, :]
y_y = y_true[:, :, 1:256, :] - y_true[:, :, 0:255, :]
y_bar_x = y_pred[:, 1:256, :, :] - y_pred[:, 0:255, :, :]
y_bar_y = y_pred[:, :, 1:256, :] - y_pred[:, :, 0:255, :]
L_tv = K.mean(K.abs(y_x - y_bar_x)) + K.mean(K.abs(y_y - y_bar_y))

# variance of the error loss
E = y_pred - y_true
L_var = K.mean(K.mean(K.square(E), axis=(1, 2, 3)) - K.square(K.mean(E, axis=(1, 2, 3))))

loss = L_var + 0.1 * L_tv
return loss

in the function :
y_x = y_true[:, 1:256, :, :] - y_true[:, 0:255, :, :]
y_y = y_true[:, :, 1:256, :] - y_true[:, :, 0:255, :]
y_bar_x = y_pred[:, 1:256, :, :] - y_pred[:, 0:255, :, :]
y_bar_y = y_pred[:, :, 1:256, :] - y_pred[:, :, 0:255, :]
why is not by thoes ?
y_x = y_true[:, 0:256, :, :] - y_true[:, 0:256, :, :]
y_y = y_true[:, :, 0:256, :] - y_true[:, :, 0:256, :]
y_bar_x = y_pred[:, 0:256, :, :] - y_pred[:, 0:256, :, :]
y_bar_y = y_pred[:, :, 0:256, :] - y_pred[:, :, 0:256, :]

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

No branches or pull requests

1 participant