Ejemplo n.º 1
0
 def default_generator(
     self,
     dataset: dc.data.Dataset,
     epochs: int = 1,
     mode: str = 'fit',
     deterministic: bool = True,
     pad_batches: bool = True) -> Iterable[Tuple[List, List, List]]:
   empty: np.ndarray = np.array([])
   for epoch in range(epochs):
     for (X_b, y_b, w_b, ids_b) in dataset.iterbatches(
         batch_size=self.batch_size,
         deterministic=deterministic,
         pad_batches=pad_batches):
       if y_b is not None:
         y_b = y_b.reshape(-1, self.n_tasks, 1)
       if X_b is not None:
         if mode == 'fit':
           for transformer in self.fit_transformers:
             X_b, _, _, _ = transformer.transform_array(
                 X_b, empty, empty, empty)
       if mode == 'predict':
         dropout = np.array(0.0)
       else:
         dropout = np.array(1.0)
       yield ([X_b, dropout], [y_b], [w_b])
Ejemplo n.º 2
0
 def default_generator(
     self,
     dataset: dc.data.Dataset,
     epochs: int = 1,
     mode: str = 'fit',
     deterministic: bool = True,
     pad_batches: bool = True) -> Iterable[Tuple[List, List, List]]:
   for epoch in range(epochs):
     for (X_b, y_b, w_b, ids_b) in dataset.iterbatches(
         batch_size=self.batch_size,
         deterministic=deterministic,
         pad_batches=pad_batches):
       yield ([X_b], [y_b], [w_b])
Ejemplo n.º 3
0
 def default_generator(
         self,
         dataset: dc.data.Dataset,
         epochs: int = 1,
         mode: str = 'fit',
         deterministic: bool = True,
         pad_batches: bool = True) -> Iterable[Tuple[List, List, List]]:
     for epoch in range(epochs):
         for (X_b, y_b, w_b,
              ids_b) in dataset.iterbatches(batch_size=self.batch_size,
                                            deterministic=deterministic,
                                            pad_batches=pad_batches):
             if y_b is not None:
                 y_b = to_one_hot(y_b.flatten(), self.n_classes).reshape(
                     -1, self.n_tasks, self.n_classes)
             yield ([X_b], [y_b], [w_b])
Ejemplo n.º 4
0
 def default_generator(
         self,
         dataset: dc.data.Dataset,
         epochs: int = 1,
         mode: str = 'fit',
         deterministic: bool = True,
         pad_batches: bool = True) -> Iterable[Tuple[List, List, List]]:
     for epoch in range(epochs):
         for (X_b, y_b, w_b,
              ids_b) in dataset.iterbatches(batch_size=self.batch_size,
                                            deterministic=deterministic,
                                            pad_batches=pad_batches):
             if mode == 'predict':
                 dropout = np.array(0.0)
             else:
                 dropout = np.array(1.0)
             yield ([X_b, dropout], [y_b], [w_b])