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
## | |
# Author: Caio Marcellos | |
# Email: [email protected] | |
## | |
import os | |
import numpy as np | |
import json | |
import glob | |
from datetime import datetime | |
from pathlib import Path |
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
class Loss_combine(nn.Module): | |
def __init__(self): | |
super().__init__() | |
def forward(self, input, target,reduction='mean'): | |
x1,x2,x3 = input | |
x1,x2,x3 = x1.half(),x2.half(),x3.half() | |
y = target.long() | |
return 0.7*F.cross_entropy(x1,y[:,0],reduction=reduction)+ 0.1*F.cross_entropy(x2,y[:,1],reduction=reduction) + \ | |
0.1*F.cross_entropy(x3,y[:,2],reduction=reduction) |