sample_input_masks#
- bayesflow.utils.sample_input_masks(subnet: Layer, x: Tensor, conditions: Tensor | None, subnet_kwargs: dict, training: bool, fixed_target_prob: float, missing_target_prob: float, missing_conditions_prob: float, seed_generator: SeedGenerator = None) tuple[Tensor | float, Tensor | float, dict][source]#
Generate the target and condition masks and populate
subnet_kwargs.The diffusion type inference networks (diffusion, flow matching, consistency) share the same input-masking scheme:
fixed_target_probrandomly fixes some targets to their known value (so the network can condition on them),missing_target_probrandomly marks fixed targets as missing, andmissing_conditions_probrandomly marks conditions as missing, so the network learns to handle missing fields. The masks are forwarded to subnets that accept them (e.g.diffusion_transformer).- Returns:
- mask_xTensor or float
The per-target inference mask (
1= inferred/noised,0= fixed).- loss_maskTensor or float
The mask the caller applies to the loss.
- subnet_kwargsdict
The keyword arguments, with mask entries added for subnets that accept them.