peal.data.custom_datasets.FunnyNodulesDataset¶
- class peal.data.custom_datasets.FunnyNodulesDataset[source]¶
Bases:
Image2MixedDatasetSynthetic nodules whose internal structure is confounded by roundness.
FunnyNodulesDatasetGeneratorwrites the dataset on first use and only supportsconfig.confounder_probability == 0.5: the unpoisoned pool has to exist before a poisoned variant can be derived from it. An oracle over the six nodule attributes is loaded from the first existing of$PEAL_RUNS/funnynodules_roundness_confounding_size/torchvision/ foundation_poisoned098/model.cpland the same path underfunnynodules/; it backssample_to_2d_latent.- Parameters:
config (
DataConfig) – Usesdataset_path,confounder_probabilityandconfounding_factors.**kwargs – Forwarded to
Image2MixedDataset.
- Variables:
oracle (
torch.nn.ModuleorNone) – Attribute predictor in eval mode, orNoneif no checkpoint exists.- Raises:
NotImplementedError – If the dataset has to be generated but
confounder_probabilityis not 0.5.
Methods
Oracle attribute readout, reduced to the confounding factors.
Attributes
- __init__(config, **kwargs)[source]¶
Generate the dataset if missing and load the first available oracle.
- Parameters:
config (DataConfig)
- sample_to_2d_latent(sample, mask=None)[source]¶
Oracle attribute readout, reduced to the confounding factors.
- Parameters:
sample (
torch.Tensor) – Image[C, H, W]or batch[N, C, H, W]; a single image is unsqueezed for the oracle and squeezed again afterwards.mask (
torch.Tensor, optional) – Ignored; kept for interface compatibility.
- Returns:
Oracle outputs for the attributes named in
config.confounding_factors, or all outputs if that is unset.- Return type:
- Raises:
RuntimeError – If no oracle checkpoint was found at construction time.