def iterator(self, mode=None, batch_size=None, num_batches=None, topo=None, targets=None, rng=None): # TODO: Refactor, deduplicate with DenseDesignMatrix.iterator if mode is None: if hasattr(self, '_iter_subset_class'): mode = self._iter_subset_class else: raise ValueError('iteration mode not provided and no default ' 'mode set for %s' % str(self)) else: mode = resolve_iterator_class(mode) if batch_size is None: batch_size = getattr(self, '_iter_batch_size', None) if num_batches is None: num_batches = getattr(self, '_iter_num_batches', None) if topo is None: topo = getattr(self, '_iter_topo', False) if targets is None: targets = getattr(self, '_iter_targets', False) if rng is None and mode.stochastic: rng = self.rng return FiniteDatasetIteratorPyTables( self, mode(self.X.shape[0], batch_size, num_batches, rng), topo, targets)
def iterator(self, mode=None, batch_size=None, num_batches=None, topo=None, targets=None, rng=None, data_specs=None, return_tuple=False): warnings.warn( "Overloading this method is not necessary with the new " "interface change and this will be removed around November " "7th 2013", stacklevel=2) if topo is not None or targets is not None: if data_specs is not None: raise ValueError( "In DenseDesignMatrix.iterator, both " "the `data_specs` argument and deprecated arguments " "`topo` or `targets` were provided.", (data_specs, topo, targets)) warnings.warn( "Usage of `topo` and `target` arguments are being " "deprecated, and will be removed around November 7th, " "2013. `data_specs` should be used instead.", stacklevel=2) # build data_specs from topo and targets if needed if topo is None: topo = getattr(self, '_iter_topo', False) if topo: # self.iterator is called without a data_specs, and with # "topo=True", so we use the default topological space # stored in self.X_topo_space assert self.X_topo_space is not None X_space = self.X_topo_space else: X_space = self.X_space if targets is None: targets = getattr(self, '_iter_targets', False) if targets: assert self.y is not None y_space = self.data_specs[0][1] space = (X_space, y_space) source = ('features', 'targets') else: space = X_space source = 'features' data_specs = (space, source) _deprecated_interface = True else: _deprecated_interface = False # TODO: Refactor if mode is None: if hasattr(self, '_iter_subset_class'): mode = self._iter_subset_class else: raise ValueError('iteration mode not provided and no default ' 'mode set for %s' % str(self)) else: mode = resolve_iterator_class(mode) if batch_size is None: batch_size = getattr(self, '_iter_batch_size', None) if num_batches is None: num_batches = getattr(self, '_iter_num_batches', None) if rng is None and mode.stochastic: rng = self.rng if data_specs is None: data_specs = self._iter_data_specs if _deprecated_interface: return FiniteDatasetIteratorPyTables(self, mode(self.X.shape[0], batch_size, num_batches, rng), data_specs=data_specs, return_tuple=return_tuple) else: return FiniteDatasetIterator(self, mode(self.X.shape[0], batch_size, num_batches, rng), data_specs=data_specs, return_tuple=return_tuple)