Python numpy.array_split() Examples
The following are 30
code examples of numpy.array_split().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.

Example #1
Source File: TargetingSystem.py From poeai with MIT License | 7 votes |
def Train(self, C, A, Y, SF): ''' Train the classifier using the sample matrix A and target matrix Y ''' C.fit(A, Y) YH = np.zeros(Y.shape, dtype = np.object) for i in np.array_split(np.arange(A.shape[0]), 32): #Split up verification into chunks to prevent out of memory YH[i] = C.predict(A[i]) s1 = SF(Y, YH) print('All:{:8.6f}'.format(s1)) ''' ss = ShuffleSplit(random_state = 1151) #Use fixed state for so training can be repeated later trn, tst = next(ss.split(A, Y)) #Make train/test split mi = [8] * 1 #Maximum number of iterations at each iter YH = np.zeros((A.shape[0]), dtype = np.object) for mic in mi: #Chunk size to split dataset for CV results #C.SetMaxIter(mic) #Set the maximum number of iterations to run #C.fit(A[trn], Y[trn]) #Perform training iterations '''
Example #2
Source File: np_box_list_ops.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #3
Source File: np_box_list_ops.py From object_detector_app with MIT License | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #4
Source File: np_box_list_ops.py From cartoonify with MIT License | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #5
Source File: np_box_list_ops.py From DOTA_models with Apache License 2.0 | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #6
Source File: np_box_list_ops.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #7
Source File: bc.py From garage with MIT License | 6 votes |
def _train_once(self, runner, epoch): """Obtain samplers and train for one epoch. Args: runner (LocalRunner): LocalRunner to which may be used to obtain samples. epoch (int): The current epoch. Returns: List[float]: Losses. """ batch = self._obtain_samples(runner, epoch) indices = np.random.permutation(len(batch.actions)) minibatches = np.array_split(indices, self._minibatches_per_epoch) losses = [] for minibatch in minibatches: observations = np_to_torch(batch.observations[minibatch]) actions = np_to_torch(batch.actions[minibatch]) self._optimizer.zero_grad() loss = self._compute_loss(observations, actions) loss.backward() losses.append(loss.item()) self._optimizer.step() return losses
Example #8
Source File: dataset.py From stable-baselines with MIT License | 6 votes |
def iterbatches(arrays, *, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): """ Iterates over arrays in batches, must provide either num_batches or batch_size, the other must be None. :param arrays: (tuple) a tuple of arrays :param num_batches: (int) the number of batches, must be None is batch_size is defined :param batch_size: (int) the size of the batch, must be None is num_batches is defined :param shuffle: (bool) enable auto shuffle :param include_final_partial_batch: (bool) add the last batch if not the same size as the batch_size :return: (tuples) a tuple of a batch of the arrays """ assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n_samples = arrays[0].shape[0] assert all(a.shape[0] == n_samples for a in arrays[1:]) inds = np.arange(n_samples) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n_samples, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #9
Source File: interSubs.py From interSubs with MIT License | 6 votes |
def split_long_lines(line, chunks = 2, max_symbols_per_line = False): if max_symbols_per_line: chunks = 0 while 1: chunks += 1 new_lines = [] for i in range(chunks): new_line = ' '.join(numpy.array_split(line.split(' '), chunks)[i]) new_lines.append(new_line) if len(max(new_lines, key = len)) <= max_symbols_per_line: return '\n'.join(new_lines) else: new_lines = [] for i in range(chunks): new_line = ' '.join(numpy.array_split(line.split(' '), chunks)[i]) new_lines.append(new_line) return '\n'.join(new_lines)
Example #10
Source File: longtermmean.py From yatsm with MIT License | 6 votes |
def group_years(years, interval=3): """ Return integers representing sequential groupings of years Note: years specified must be sorted Args: years (np.ndarray): the year corresponding to each EVI value interval (int, optional): number of years to group together (default: 3) Returns: np.ndarray: integers representing sequential year groupings """ n_groups = math.ceil((years.max() - years.min()) / interval) if n_groups <= 1: return np.zeros_like(years, dtype=np.uint16) splits = np.array_split(np.arange(years.min(), years.max() + 1), n_groups) groups = np.zeros_like(years, dtype=np.uint16) for i, s in enumerate(splits): groups[np.in1d(years, s)] = i return groups
Example #11
Source File: infl.py From sgd-influence with MIT License | 6 votes |
def compute_gradient(model, loss_fn, device, dataset, idx): n = idx.size grad_idx = np.array_split(np.arange(n), test_batch_size) u = [torch.zeros(*param.shape, requires_grad=False).to(device) for param in model.parameters()] model.eval() for i in grad_idx: X = [] y = [] for ii in i: d = dataset[idx[ii]] X.append(d[0]) y.append(d[1]) X = torch.stack(X).to(device) y = torch.from_numpy(np.array(y)).to(device) z = model(X) loss = loss_fn(z, y, reduction='sum') model.zero_grad() loss.backward() for j, param in enumerate(model.parameters()): u[j] += param.grad.data / n return u
Example #12
Source File: outlier.py From sgd-influence with MIT License | 6 votes |
def eval_model(model, loss_fn, device, dataset, idx): model.eval() n = idx.size with torch.no_grad(): loss = 0 eval_idx = np.array_split(np.arange(n), test_batch_size) for i in eval_idx: x = [] for ii in i: d = dataset[idx[ii]] x.append(d[0]) x = torch.stack(x).to(device) y = model(x) loss += loss_fn(y, x).item() * i.size loss /= n return loss
Example #13
Source File: np_box_list_ops.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #14
Source File: digits_adjust.py From OpenCV-Python-Tutorial with MIT License | 6 votes |
def cross_validate(model_class, params, samples, labels, kfold = 3, pool = None): n = len(samples) folds = np.array_split(np.arange(n), kfold) def f(i): model = model_class(**params) test_idx = folds[i] train_idx = list(folds) train_idx.pop(i) train_idx = np.hstack(train_idx) train_samples, train_labels = samples[train_idx], labels[train_idx] test_samples, test_labels = samples[test_idx], labels[test_idx] model.train(train_samples, train_labels) resp = model.predict(test_samples) score = (resp != test_labels).mean() print(".", end='') return score if pool is None: scores = list(map(f, xrange(kfold))) else: scores = pool.map(f, xrange(kfold)) return np.mean(scores)
Example #15
Source File: train.py From sgd-influence with MIT License | 6 votes |
def eval_model(model, loss_fn, device, dataset, idx): model.eval() n = idx.size with torch.no_grad(): loss = 0 acc = 0 eval_idx = np.array_split(np.arange(n), test_batch_size) for i in eval_idx: X = [] y = [] for ii in i: d = dataset[idx[ii]] X.append(d[0]) y.append(d[1]) X = torch.stack(X).to(device) y = torch.from_numpy(np.array(y)).to(device) z = model(X) loss += loss_fn(z, y, reduction='sum').item() pred = z.argmax(dim=1, keepdim=True) acc += pred.eq(y.view_as(pred)).sum().item() loss /= n acc /= n return loss, acc
Example #16
Source File: np_box_list_ops.py From SlowFast-Network-pytorch with MIT License | 6 votes |
def scale(boxlist, y_scale, x_scale): """Scale box coordinates in x and y dimensions. Args: boxlist: BoxList holding N boxes y_scale: float x_scale: float Returns: boxlist: BoxList holding N boxes """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) y_min = y_scale * y_min y_max = y_scale * y_max x_min = x_scale * x_min x_max = x_scale * x_max scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max])) fields = boxlist.get_extra_fields() for field in fields: extra_field_data = boxlist.get_field(field) scaled_boxlist.add_field(field, extra_field_data) return scaled_boxlist
Example #17
Source File: _eigenpro.py From scikit-learn-extra with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _raw_predict(self, X): """Predict using the kernel regression model Parameters ---------- X : {float, array}, shape = [n_samples, n_features] Samples. Returns ------- Y : {float, array}, shape = [n_samples, n_targets] Predicted targets. """ check_is_fitted( self, ["bs_", "centers_", "coef_", "was_1D_", "gamma_"] ) X = np.asarray(X, dtype=np.float64) if len(X.shape) == 1: raise ValueError( "Reshape your data. X should be a matrix of shape" " (n_samples, n_features)." ) n = X.shape[0] Ys = [] for batch_inds in np.array_split(range(n), max(1, n // self.bs_)): batch_x = X[batch_inds] kfeat = self._kernel(batch_x, self.centers_) pred = np.dot(kfeat, self.coef_) Ys.append(pred) Y = np.vstack(Ys) if self.was_1D_: Y = np.reshape(Y, Y.shape[0]) return Y
Example #18
Source File: dataset.py From learning2run with MIT License | 5 votes |
def iterbatches(arrays, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n = arrays[0].shape[0] assert all(a.shape[0] == n for a in arrays[1:]) inds = np.arange(n) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #19
Source File: np_box_list_ops.py From cartoonify with MIT License | 5 votes |
def prune_outside_window(boxlist, window): """Prunes bounding boxes that fall outside a given window. This function prunes bounding boxes that even partially fall outside the given window. See also ClipToWindow which only prunes bounding boxes that fall completely outside the window, and clips any bounding boxes that partially overflow. Args: boxlist: a BoxList holding M_in boxes. window: a numpy array of size 4, representing [ymin, xmin, ymax, xmax] of the window. Returns: pruned_corners: a tensor with shape [M_out, 4] where M_out <= M_in. valid_indices: a tensor with shape [M_out] indexing the valid bounding boxes in the input tensor. """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] coordinate_violations = np.hstack([np.less(y_min, win_y_min), np.less(x_min, win_x_min), np.greater(y_max, win_y_max), np.greater(x_max, win_x_max)]) valid_indices = np.reshape( np.where(np.logical_not(np.max(coordinate_violations, axis=1))), [-1]) return gather(boxlist, valid_indices), valid_indices
Example #20
Source File: dataset.py From DRL_DeliveryDuel with MIT License | 5 votes |
def iterbatches(arrays, *, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n = arrays[0].shape[0] assert all(a.shape[0] == n for a in arrays[1:]) inds = np.arange(n) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #21
Source File: dataset.py From ICML2019-TREX with MIT License | 5 votes |
def iterbatches(arrays, *, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n = arrays[0].shape[0] assert all(a.shape[0] == n for a in arrays[1:]) inds = np.arange(n) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #22
Source File: dataset.py From ICML2019-TREX with MIT License | 5 votes |
def iterbatches(arrays, *, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n = arrays[0].shape[0] assert all(a.shape[0] == n for a in arrays[1:]) inds = np.arange(n) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #23
Source File: misc.py From Computable with MIT License | 5 votes |
def _split_quantile(arr, k): arr = np.asarray(arr) mask = np.isfinite(arr) order = arr[mask].argsort() n = len(arr) return np.array_split(np.arange(n)[mask].take(order), k)
Example #24
Source File: experiment.py From Neural-LP with MIT License | 5 votes |
def get_attentions(self): if self.option.query_is_language: num_batch = int(np.ceil(1.0*len(self.data.query_for_rules)/self.option.batch_size)) query_batches = np.array_split(self.data.query_for_rules, num_batch) else: #print(self.data.query_for_rules) if not self.option.type_check: num_batch = int(np.ceil(1.*len(self.data.query_for_rules)/self.option.batch_size)) query_batches = np.array_split(self.data.query_for_rules, num_batch) else: query_batches = [[i] for i in self.data.query_for_rules] all_attention_operators = {} all_attention_memories = {} for queries in query_batches: attention_operators, attention_memories \ = self.learner.get_attentions_given_queries(self.sess, queries) # Tuple-ize in order to be used as dict keys if self.option.query_is_language: queries = [tuple(q) for q in queries] for i in xrange(len(queries)): all_attention_operators[queries[i]] \ = [[attn[i] for attn in attn_step] for attn_step in attention_operators] all_attention_memories[queries[i]] = \ [attn_step[i, :] for attn_step in attention_memories] pickle.dump([all_attention_operators, all_attention_memories], open(os.path.join(self.option.this_expsdir, "attentions.pckl"), "w")) msg = self.msg_with_time("Attentions collected.") print(msg) self.log_file.write(msg + "\n") all_queries = reduce(lambda x,y: list(x) + list(y), query_batches, []) return all_attention_operators, all_attention_memories, all_queries
Example #25
Source File: operators.py From pyswarms with MIT License | 5 votes |
def compute_objective_function(swarm, objective_func, pool=None, **kwargs): """Evaluate particles using the objective function This method evaluates each particle in the swarm according to the objective function passed. If a pool is passed, then the evaluation of the particles is done in parallel using multiple processes. Parameters ---------- swarm : pyswarms.backend.swarms.Swarm a Swarm instance objective_func : function objective function to be evaluated pool: multiprocessing.Pool multiprocessing.Pool to be used for parallel particle evaluation kwargs : dict arguments for the objective function Returns ------- numpy.ndarray Cost-matrix for the given swarm """ if pool is None: return objective_func(swarm.position, **kwargs) else: results = pool.map( partial(objective_func, **kwargs), np.array_split(swarm.position, pool._processes), ) return np.concatenate(results)
Example #26
Source File: ops.py From glas with Apache License 2.0 | 5 votes |
def get_folds(sources, num_folds, fold, holdout): """ Get the folds for the data set. """ if num_folds < 2: return sources folds = np.array_split(sources, num_folds) return folds[fold] if holdout else np.concatenate(folds[:fold] + folds[fold + 1:])
Example #27
Source File: dataset.py From rl_graph_generation with BSD 3-Clause "New" or "Revised" License | 5 votes |
def iterbatches(arrays, *, num_batches=None, batch_size=None, shuffle=True, include_final_partial_batch=True): assert (num_batches is None) != (batch_size is None), 'Provide num_batches or batch_size, but not both' arrays = tuple(map(np.asarray, arrays)) n = arrays[0].shape[0] assert all(a.shape[0] == n for a in arrays[1:]) inds = np.arange(n) if shuffle: np.random.shuffle(inds) sections = np.arange(0, n, batch_size)[1:] if num_batches is None else num_batches for batch_inds in np.array_split(inds, sections): if include_final_partial_batch or len(batch_inds) == batch_size: yield tuple(a[batch_inds] for a in arrays)
Example #28
Source File: test_base_execute.py From mars with Apache License 2.0 | 5 votes |
def testArraySplitExecution(self): x = arange(48, chunk_size=3).reshape(2, 3, 8) ss = array_split(x, 3, axis=2) res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss] expected = np.array_split(np.arange(48).reshape(2, 3, 8), 3, axis=2) self.assertEqual(len(res), len(expected)) [np.testing.assert_equal(r, e) for r, e in zip(res, expected)] ss = array_split(x, [3, 5, 6, 10], axis=2) res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss] expected = np.array_split(np.arange(48).reshape(2, 3, 8), [3, 5, 6, 10], axis=2) self.assertEqual(len(res), len(expected)) [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]
Example #29
Source File: np_box_list_ops.py From SlowFast-Network-pytorch with MIT License | 5 votes |
def prune_outside_window(boxlist, window): """Prunes bounding boxes that fall outside a given window. This function prunes bounding boxes that even partially fall outside the given window. See also ClipToWindow which only prunes bounding boxes that fall completely outside the window, and clips any bounding boxes that partially overflow. Args: boxlist: a BoxList holding M_in boxes. window: a numpy array of size 4, representing [ymin, xmin, ymax, xmax] of the window. Returns: pruned_corners: a tensor with shape [M_out, 4] where M_out <= M_in. valid_indices: a tensor with shape [M_out] indexing the valid bounding boxes in the input tensor. """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] coordinate_violations = np.hstack([np.less(y_min, win_y_min), np.less(x_min, win_x_min), np.greater(y_max, win_y_max), np.greater(x_max, win_x_max)]) valid_indices = np.reshape( np.where(np.logical_not(np.max(coordinate_violations, axis=1))), [-1]) return gather(boxlist, valid_indices), valid_indices
Example #30
Source File: np_box_list_ops.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def prune_outside_window(boxlist, window): """Prunes bounding boxes that fall outside a given window. This function prunes bounding boxes that even partially fall outside the given window. See also ClipToWindow which only prunes bounding boxes that fall completely outside the window, and clips any bounding boxes that partially overflow. Args: boxlist: a BoxList holding M_in boxes. window: a numpy array of size 4, representing [ymin, xmin, ymax, xmax] of the window. Returns: pruned_corners: a tensor with shape [M_out, 4] where M_out <= M_in. valid_indices: a tensor with shape [M_out] indexing the valid bounding boxes in the input tensor. """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] coordinate_violations = np.hstack([np.less(y_min, win_y_min), np.less(x_min, win_x_min), np.greater(y_max, win_y_max), np.greater(x_max, win_x_max)]) valid_indices = np.reshape( np.where(np.logical_not(np.max(coordinate_violations, axis=1))), [-1]) return gather(boxlist, valid_indices), valid_indices