pymic.net_run.noisy_label package
Submodules
pymic.net_run.noisy_label.nll_clslsr module
- class pymic.net_run.noisy_label.nll_clslsr.NLLCLSLSR(config, stage='test')
Bases:
SegmentationAgentAn agent to estimatate the confidence of noisy labels during inference.
Reference: Minqing Zhang et al., Characterizing Label Errors: Confident Learning for Noisy-Labeled Image Segmentation, MICCAI 2020.
- Parameters:
config – (dict) A dictionary containing the configuration.
stage – (str) One of the stage in train (default), inference or test.
- infer_with_cl()
Inference with confidence estimation.
- pymic.net_run.noisy_label.nll_clslsr.get_confidence_map(cfg_file)
- pymic.net_run.noisy_label.nll_clslsr.get_confident_map(gt, pred, CL_type='both')
Get the confidence map based on the label and prediction.
- Parameters:
gt – (tensor) One-hot label with shape of NXC.
pred – (tensor) Digit prediction of network with shape of NXC.
CL_type – (str) A string in {‘both’, ‘Qij’, ‘Cij’, ‘intersection’, ‘union’, ‘prune_by_class’, ‘prune_by_noise_rate’}.
- Returns:
A tensor representing the noisiness of each pixel.
pymic.net_run.noisy_label.nll_co_teaching module
- class pymic.net_run.noisy_label.nll_co_teaching.BiNet(params)
Bases:
Module- forward(x)
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class pymic.net_run.noisy_label.nll_co_teaching.NLLCoTeaching(config, stage='train')
Bases:
SegmentationAgentCo-teaching for noisy-label learning.
Reference: Bo Han, Quanming Yao, Xingrui Yu, Gang Niu, Miao Xu, Weihua Hu, Ivor Tsang, Masashi Sugiyama. Co-teaching: Robust Training of Deep Neural Networks with Extremely Noisy Labels. NeurIPS 201.
- Parameters:
config – (dict) A dictionary containing the configuration.
stage – (str) One of the stage in train (default), inference or test.
Note
In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section noisy_label_learning is needed. See Noisy Label Learning for details.
- create_network()
Create network based on configuration.
- training()
Train the network
- write_scalars(train_scalars, valid_scalars, lr_value, glob_it)
Write scalars using SummaryWriter.
- Parameters:
train_scalars – (dictionary) Scalars for training set.
valid_scalars – (dictionary) Scalars for validation set.
lr_value – (float) Current learning rate.
glob_it – (int) Current iteration number.
pymic.net_run.noisy_label.nll_dast module
- class pymic.net_run.noisy_label.nll_dast.ConsistLoss
Bases:
Module- forward(input1, input2, size_average=True)
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- kl_div_map(input, label)
- kl_loss(input, target, size_average=True)
- class pymic.net_run.noisy_label.nll_dast.NLLDAST(config, stage='train')
Bases:
SegmentationAgentDivergence-Aware Selective Training for noisy label learning.
Reference: Shuojue Yang, Guotai Wang, Hui Sun, Xiangde Luo, Peng Sun, Kang Li, Qijun Wang, Shaoting Zhang: Learning COVID-19 Pneumonia Lesion Segmentation from Imperfect Annotations via Divergence-Aware Selective Training. JBHI 2022.
- Parameters:
config – (dict) A dictionary containing the configuration.
stage – (str) One of the stage in train (default), inference or test.
Note
In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section noisy_label_learning is needed. See Noisy Label Learning for details.
- create_dataset()
Create datasets for training, validation or testing based on configuraiton.
- get_noisy_dataset_from_config()
Create a dataset for images with noisy labels based on configuraiton.
- train_valid()
Train and valid.
- training()
Train the network
- class pymic.net_run.noisy_label.nll_dast.Rank(quene_length=100)
Bases:
objectDynamically rank the current training sample with specific metrics.
- Parameters:
quene_length – (int) The lenght for a quene.
- add_val(val)
Update the quene and calculate the order of the input value.
- Parameters:
val – (float) a value adding to the quene.
- Returns:
rank of the input value with a range of (0, self.quene_length)
- pymic.net_run.noisy_label.nll_dast.get_ce(prob, soft_y, size_avg=True)
- pymic.net_run.noisy_label.nll_dast.select_criterion(no_noisy_sample, cl_noisy_sample, label)
Obtain the sample selection criterion score.
- Parameters:
no_noisy_sample – noisy branch’s output probability for noisy sample.
cl_noisy_sample – clean branch’s output probability for noisy sample.
label – noisy label.
pymic.net_run.noisy_label.nll_trinet module
- class pymic.net_run.noisy_label.nll_trinet.NLLTriNet(config, stage='train')
Bases:
SegmentationAgentImplementation of trinet for learning from noisy samples for segmentation tasks.
Reference: Tianwei Zhang, Lequan Yu, Na Hu, Su Lv, Shi Gu: Robust Medical Image Segmentation from Non-expert Annotations with Tri-network. MICCAI 2020.
- Parameters:
config – (dict) A dictionary containing the configuration.
stage – (str) One of the stage in train (default), inference or test.
Note
In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section noisy_label_learning is needed. See Noisy Label Learning for details.
- create_network()
Create network based on configuration.
- get_loss_and_confident_mask(pred, labels_prob, conf_ratio)
- training()
Train the network
- write_scalars(train_scalars, valid_scalars, lr_value, glob_it)
Write scalars using SummaryWriter.
- Parameters:
train_scalars – (dictionary) Scalars for training set.
valid_scalars – (dictionary) Scalars for validation set.
lr_value – (float) Current learning rate.
glob_it – (int) Current iteration number.
- class pymic.net_run.noisy_label.nll_trinet.TriNet(params)
Bases:
Module- forward(x)
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.