def __init__(self, cardinalities, seed=None): Classifier.__init__(self) self.multitask = True self.K = cardinalities if seed is None: seed = np.random.randint(1e6) self._set_seed(seed)
def __init__(self, K, config): Classifier.__init__(self, None, config) self.multitask = True self.K = K
def _stack_batches(X): """Given a list of batches, each consisting of a T-len list of np.ndarrays, stack along the first (batch) axis, returning a T-len list of np.ndarrays.""" return [Classifier._stack_batches(Xt) for Xt in zip(*X)]
def _to_numpy(Z): """Converts a None, list, np.ndarray, or torch.Tensor to np.ndarray""" if isinstance(Z, list): return [Classifier._to_numpy(z) for z in Z] else: return Classifier._to_numpy(Z)
def _to_torch(Z, dtype=None): """Converts a None, list, np.ndarray, or torch.Tensor to torch.Tensor""" if isinstance(Z, list): return [Classifier._to_torch(z, dtype=dtype) for z in Z] else: return Classifier._to_torch(Z)