def from_dataset(dataset, num_examples):
 if (dataset.view_converter is not None):
  try:
   (V, y) = dataset.get_batch_topo(num_examples, True)
  except TypeError:
   if (isinstance(dataset, DenseDesignMatrix) and (dataset.X is None) and (not control.get_load_data())):
    warnings.warn("from_dataset wasn't able to make subset of dataset, using the whole thing")
    return DenseDesignMatrix(X=None, view_converter=dataset.view_converter)
   raise
  rval = DenseDesignMatrix(topo_view=V, y=y, y_labels=dataset.y_labels)
  rval.adjust_for_viewer = dataset.adjust_for_viewer
 else:
  (X, y) = dataset.get_batch_design(num_examples, True)
  rval = DenseDesignMatrix(X=X, y=y, y_labels=dataset.y_labels)
 return rval

def from_dataset ( dataset , num_examples ) : if ( dataset . view_converter is not None ) : try : ( V , y ) = dataset . get_batch_topo ( num_examples , True ) except TypeError : if ( isinstance ( dataset , DenseDesignMatrix ) and ( dataset . X is None ) and ( not control . get_load_data ( ) ) ) : warnings . warn ( "from_dataset wasn't able to make subset of dataset, using the whole thing" ) return DenseDesignMatrix ( X = None , view_converter = dataset . view_converter ) raise rval = DenseDesignMatrix ( topo_view = V , y = y , y_labels = dataset . y_labels ) rval . adjust_for_viewer = dataset . adjust_for_viewer else : ( X , y ) = dataset . get_batch_design ( num_examples , True ) rval = DenseDesignMatrix ( X = X , y = y , y_labels = dataset . y_labels ) return rval
constructs a random subset of a densedesignmatrix parameters dataset : densedesignmatrix num_examples : int returns sub_dataset : densedesignmatrix a new dataset containing num_examples examples .