Created
December 29, 2020 10:08
-
-
Save level14taken/f32fbbcfebb67eb5c6c5ba19626068e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_losslv_simple(model,inp): | |
no_mask,final=model(inp[0]) | |
final=final*inp[-1].view(-1,1,1,1) | |
mfl=nn.BCEWithLogitsLoss() | |
lv=LovaszLoss() | |
weights=[.1/2.1,2/2.1] | |
loss=[mfl(no_mask.view(-1,1,1,1),inp[-1].view(-1,1,1,1)),lv(final,inp[1])] | |
accuracy=acc(no_mask.reshape(-1),inp[-1],center=True)/len(inp[-1]) | |
loss=sum(x_i*y_i for x_i, y_i in zip(weights, loss)) | |
return loss,accuracy,final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment