关于NiftyNet中Sample_per_volume参数采样逻辑的技术咨询
sample_per_volume Behavior Hey there! Let me break down your observations and assumptions about NiftyNet's sample_per_volume parameter based on my hands-on experience with the framework.
Your Observation is Correct
Yes, your monitoring of the sampling behavior aligns perfectly with how NiftyNet operates. The sample_per_volume parameter does not restrict a volume to only one sample for the entire training process. Instead, it controls how many patches are generated from a single volume per training iteration.
When set to 1, every time a volume is selected to be part of the current training batch, it will contribute exactly one random patch to that batch. Over multiple iterations, the same volume can be selected repeatedly, each time generating a new random patch—so you're not limited to just one patch per volume overall.
On Your Optimal Randomization Assumption
Your hypothesis that sample_per_volume=1 enhances sampling randomization is generally valid, though it depends on your dataset size and training goals:
- Randomization benefits: This setting ensures each iteration draws patches from a wider variety of volumes (assuming your dataset has enough samples). It prevents over-sampling specific volumes in a single batch, which helps the model learn more generalized features across different cases.
- Small dataset caveat: If you only have a limited number of volumes,
sample_per_volume=1might lead to low diversity in individual batches. In this scenario, you could slightly increase the parameter (e.g., to 2 or 3) or pair it with aggressive data augmentation to maintain batch diversity.
Quick Additional Tip
If you want to control the total number of times a volume is sampled across the entire training run, you'll need to factor in your dataset size, batch_size, and num_epochs—sample_per_volume only governs per-iteration sampling from each selected volume.
内容的提问来源于stack exchange,提问作者Kai Wang

