def _preprocess_Y(self, Y): """Convert Y to T-dim lists of soft labels if necessary""" # If not a list, convert to a singleton list if not isinstance(Y, list): if self.T != 1: msg = "For T > 1, Y must be a list of N-dim or [N, K_t] tensors" raise ValueError(msg) Y = [Y] if not len(Y) == self.T: msg = "Expected Y to be a list of length T ({self.T}), not {len(Y)}" raise ValueError(msg) Y = [Y_t.clone() for Y_t in Y] return [EndModel._preprocess_Y(self, Y_t) for Y_t in Y]
def _preprocess_Y(self, Y): """Convert Y to t-length list of soft labels if necessary""" # If not a list, convert to a singleton list if not isinstance(Y, list): if self.t != 1: msg = "For t > 1, Y must be a list of n-dim or [n, K_t] tensors" raise ValueError(msg) Y = [Y] if not len(Y) == self.t: msg = f"Expected Y to be a t-length list (t={self.t}), not {len(Y)}" raise ValueError(msg) return [ EndModel._preprocess_Y(self, Y_t, self.K[t]) for t, Y_t in enumerate(Y) ]