예제 #1
0
import mmcv

import data_loader
from config_loader import dbg_config
import model
""" Load config
"""
checkpoint_dir = dbg_config.checkpoint_dir
batch_size = dbg_config.batch_size
learning_rate = dbg_config.learning_rate
tscale = dbg_config.tscale
feature_dim = dbg_config.feature_dim
epoch_num = dbg_config.epoch_num
""" Initialize map mask
"""
mask = data_loader.gen_mask(tscale)
mask = np.expand_dims(np.expand_dims(mask, 0), -1)
mask = tf.convert_to_tensor(mask, tf.float32)


def binary_logistic_loss(gt_scores,
                         pred_anchors,
                         label_smoothing=0,
                         weight_balance=True):
    """
    Calculate weighted binary logistic loss
    :param gt_scores: gt scores tensor
    :param pred_anchors: prediction score tensor
    :param label_smoothing: float
    :param weight_balance: bool
    :return: loss output tensor
예제 #2
0
from torch.utils.data import DataLoader

""" Load config
"""
from config_loader import dbg_config

checkpoint_dir = dbg_config.checkpoint_dir
batch_size = dbg_config.batch_size
learning_rate = dbg_config.learning_rate
tscale = dbg_config.tscale
feature_dim = dbg_config.feature_dim
epoch_num = dbg_config.epoch_num

""" Initialize map mask
"""
mask = gen_mask(tscale)
mask = np.expand_dims(np.expand_dims(mask, 0), 1)
mask = torch.from_numpy(mask).float().requires_grad_(False).cuda()
tmp_mask = mask.repeat(batch_size, 1, 1, 1).requires_grad_(False)
tmp_mask = tmp_mask > 0


def binary_logistic_loss(gt_scores, pred_anchors):
    """
    Calculate weighted binary logistic loss
    :param gt_scores: gt scores tensor
    :param pred_anchors: prediction score tensor
    :return: loss output tensor
    """
    gt_scores = gt_scores.view(-1)
    pred_anchors = pred_anchors.view(-1)