r_elias_1.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:dsb3 作者: EliasVansteenkiste 项目源码 文件源码
def build_objective(model, deterministic=False, epsilon=1e-12):
    predictions = nn.layers.get_output(model.l_out, deterministic=deterministic)
    targets = T.cast(nn.layers.get_output(model.l_target), 'int32')
    predictions = T.clip(predictions, epsilon, 1.-epsilon)

    #is_nodule_ground_truth = T.cast(targets[:,0], 'float32')

    sum_of_objectives = 0
    unit_ptr = 0
    for obj_idx, obj_name in enumerate(order_objectives):
        n_classes = len(property_bin_borders[obj_name])
        if deterministic:
            d_objectives_deterministic[obj_name] = objective(obj_idx, (unit_ptr, unit_ptr+n_classes), predictions, targets)
        else:
            d_objectives[obj_name] = objective(obj_idx, (unit_ptr, unit_ptr+n_classes), predictions, targets)
        sum_of_objectives += objective(obj_idx, (unit_ptr, unit_ptr+n_classes), predictions, targets)
        unit_ptr = unit_ptr+n_classes

    #print 'for debug purposes: unit_ptr', unit_ptr

    return sum_of_objectives
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号