def filter_labels(train, label, classes=None):
 if isinstance(train, theano.tensor.sharedvar.SharedVariable):
  train = train.get_value(borrow=True)
 if isinstance(label, theano.tensor.sharedvar.SharedVariable):
  label = label.get_value(borrow=True)
 if (not (isinstance(train, numpy.ndarray) or scipy.sparse.issparse(train))):
  raise TypeError('train must be a numpy array, a scipy sparse matrix, or a theano shared array')
 if (classes is not None):
  label = label[:, classes]
 if scipy.sparse.issparse(train):
  idx = label.sum(axis=1).nonzero()[0]
  return (train[idx], label[idx])
 condition = label.any(axis=1)
 return tuple((var.compress(condition, axis=0) for var in (train, label)))

def filter_labels ( train , label , classes = None ) : if isinstance ( train , theano . tensor . sharedvar . SharedVariable ) : train = train . get_value ( borrow = True ) if isinstance ( label , theano . tensor . sharedvar . SharedVariable ) : label = label . get_value ( borrow = True ) if ( not ( isinstance ( train , numpy . ndarray ) or scipy . sparse . issparse ( train ) ) ) : raise TypeError ( 'train must be a numpy array, a scipy sparse matrix, or a theano shared array' ) if ( classes is not None ) : label = label [ : , classes ] if scipy . sparse . issparse ( train ) : idx = label . sum ( axis = 1 ) . nonzero ( ) [ 0 ] return ( train [ idx ] , label [ idx ] ) condition = label . any ( axis = 1 ) return tuple ( ( var . compress ( condition , axis = 0 ) for var in ( train , label ) ) )
filter examples of train for which we have labels parameters train : writeme label : writeme classes : writeme returns writeme .