def GetEDLLoss(pred, true): if type(pred) is not torch.Tensor: pred = torch.Tensor(pred).float().cuda() elif pred.is_cuda is False: pred = pred.cuda() if type(true) is not torch.Tensor: true = torch.Tensor(true).float().cuda() elif true.is_cuda is False: true = true.cuda() loss = EDL_Loss()(true, pred).item() return loss
from torch import optim import joblib import os import argparse import numpy as np from model import CNNText from util import PyTorchParameterList2NPArrayList from loss import EDL_Loss # config # inner_rate = 0.01 outer_rate = 0.1 n_subsets = 5 ntrain = 10 loss_fn = EDL_Loss() print('[Start maml ...]') parser = argparse.ArgumentParser() parser.add_argument("--file_path", help="saving root path of raw data", default='./test') parser.add_argument("--seed", help="reproducible experiment with seeds", type=int) parser.add_argument("--out_dim", help="output dimension", type=int, default=6) parser.add_argument('--niterations', help='number of iterations', default=1000, type=int)