八、将标签尺寸label_shape(8,256,256),调整成预测尺寸pred_shape(8,2,256,256)

下面代码仅适用于二分类算法

import torch


def _expand_onehot_labels(labels, label_weights, target_shape, ignore_index):
    """Expand onehot labels to match the size of prediction."""
    bin_labels = labels.new_zeros(target_shape)
    valid_mask = (labels >= 

おすすめ

転載: blog.csdn.net/panchang199266/article/details/129850737