@@ -170,32 +170,32 @@ def _unroll(self, data, n_windows, unroll_length, randomize):
170170
171171 return torch .stack (windows , dim = 1 )
172172
173- def evaluate (self , batch , solver , loss ):
173+ def evaluate (self , batch , solver ):
174174 """
175175 Evaluate the residual of the condition on the given batch using the
176176 solver.
177177
178- This method computes the non-aggregated, element-wise residual of the
179- condition. A forward pass of the solver's model is performed on the
180- input samples, and the condition residual is evaluated accordingly.
178+ This method computes the per-step residuals through autoregressive
179+ unrolling. A forward pass of the solver's model is performed at each
180+ time step, and the per-step residuals (predicted - target) are
181+ returned as a stacked tensor.
181182
182- The returned tensor is not reduced, preserving the per-sample residual
183- values .
183+ The returned tensor preserves all per-step residual values without
184+ reduction or loss aggregation .
184185
185186 :param dict batch: The batch containing the data required by the
186187 condition evaluation.
187188 :param SolverInterface solver: The solver used to perform the forward
188189 pass and compute the residual. The solver provides access to the
189190 model and its parameters, which may be necessary for evaluating the
190191 condition residual.
191- :param torch.nn.Module loss: The non-aggregating loss function used to
192- compare the condition residual against its reference value.
193192 :raises ValueError: If the input tensor in the batch has less than 4
194193 dimensions.
195- :return: The non-aggregated residual tensor.
194+ :return: The stacked per-step residual tensor of shape
195+ [time_steps - 1, trajectories, windows, *features].
196196 :rtype: torch.Tensor | LabelTensor
197197 """
198- # Raise error if input tensor does not have at least4 dimensions
198+ # Raise error if input tensor does not have at least 4 dimensions
199199 if batch ["input" ].dim () < 4 :
200200 raise ValueError (
201201 "The provided input tensor must have at least 4 dimensions:"
@@ -206,9 +206,9 @@ def evaluate(self, batch, solver, loss):
206206 # Copy the kwargs to avoid modifying the original settings
207207 kwargs = solver ._kwargs .copy ()
208208
209- # Extract the initial state and initialize the list of step-wise losses
209+ # Extract the initial state and initialize the step-wise residuals list
210210 current_state = batch ["input" ][:, :, 0 ]
211- losses = []
211+ residuals = []
212212
213213 # Iterate over the time steps
214214 for step in range (1 , batch ["input" ].shape [2 ]):
@@ -218,23 +218,16 @@ def evaluate(self, batch, solver, loss):
218218 output = solver .forward (processed_input )
219219 predicted_state = solver .postprocess_step (output , ** kwargs )
220220
221- # Retrieve the target and compute the step-wise loss
221+ # Retrieve the target and compute the step-wise residual
222222 target_state = batch ["input" ][:, :, step ]
223- step_loss = loss ( predicted_state , target_state , ** kwargs )
224- losses .append (step_loss )
223+ step_residual = predicted_state - target_state
224+ residuals .append (step_residual )
225225
226226 # Update the current state for the next iteration
227227 current_state = predicted_state
228228
229- # Stack the step-wise losses
230- step_losses = torch .stack (losses ).as_subclass (torch .Tensor )
231-
232- # Compute adaptive weights and aggregate the step-wise losses
233- with torch .no_grad ():
234- name = getattr (self , "name" , None ) or "default"
235- weights = solver ._get_weights (name , step_losses )
236-
237- return solver .aggregation_strategy (step_losses * weights )
229+ # Stack the step-wise residuals
230+ return torch .stack (residuals ).as_subclass (torch .Tensor )
238231
239232 @property
240233 def input (self ):
0 commit comments