starling.inference.constraints.ReConstraint

class ReConstraint[source]

Bases: Constraint

Methods

__init__

Create constraint for end-to-end distance.

apply

Apply the constraint to the given latents.

bell_shaped_schedule

Bell-shaped schedule for time-dependent guidance strength.

compute_loss

Compute the loss for this constraint without applying gradients.

cosine_weight

Cosine schedule for time-dependent guidance strength.

get_adaptive_clip_threshold

Get an adaptive clipping threshold that follows a cosine schedule.

get_time_scale

Get the time-dependent scaling factor.

initialize

Called by the sampler to set model parameters.

should_apply_guidance

Check if guidance should be applied at the current timestep.

__init__(target, tolerance=0.0, force_constant=2.0, **kwargs)[source]

Create constraint for end-to-end distance.

compute_loss(distance_maps: Tensor) Tuple[Tensor, Tensor][source]

Compute the loss for this constraint without applying gradients.

Parameters:

distance_maps (torch.Tensor) – Pre-computed distance maps from the latents

Returns:

(per_batch_loss, total_loss) - Individual sample losses and mean loss

Return type:

tuple[torch.Tensor, torch.Tensor]