Example #1
0
    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)
Example #2
0
 def __init__(self, K, config):
     Classifier.__init__(self, None, config)
     self.multitask = True
     self.K = K
Example #3
0
 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)]
Example #4
0
 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)
Example #5
0
 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)