class_docstr: Helper for dimensionality reduction to the innermost dimension of a tensor.
  
  This class wraps sklearn.decomposition classes to help them apply to arbitrary
  rank tensors. It saves lots of annoying reshaping.
  
  See the original sklearn.decomposition documentation:
  http://scikit-learn.org/stable/modules/classes.html#module-sklearn.decomposition
class_docstr_tok: ["Helper","for","dimensionality","reduction","to","the","innermost","dimension","of","a","tensor",".","This","class","wraps","sklearn.decomposition","classes","to","help","them","apply","to","arbitrary","rank","tensors",".","It","saves","lots","of","annoying","reshaping",".","See","the","original","sklearn.decomposition","documentation",":","http",":","\/\/scikit-learn.org\/stable\/modules\/classes.html","#","module-sklearn.decomposition"]
docstr: Utility for applying f to inner dimension of acts.
  
  Flattens acts into a 2D tensor, applies f, then unflattens so that all
  dimesnions except innermost are unchanged.
docstr_tok: ["Utility","for","applying","f","to","inner","dimension","of","acts",".","Flattens","acts","into","a","2D","tensor",",","applies","f",",","then","unflattens","so","that","all","dimesnions","except","innermost","are","unchanged","."]
code: def _apply_flat(cls, f, acts):
      """Utility for applying f to inner dimension of acts.
  
      Flattens acts into a 2D tensor, applies f, then unflattens so that all
      dimesnions except innermost are unchanged.
      """
      orig_shape = acts.shape
      acts_flat = acts.reshape([-1, acts.shape[-1]])
      new_flat = f(acts_flat)
      if not isinstance(new_flat, np.ndarray):
          return new_flat
      shape = list(orig_shape[:-1]) + [-1]
      return new_flat.reshape(shape)
  
file_path: lucid/lucid/misc/channel_reducer.py
imports: import numpy
  import sklearn.decomposition
label_desc: Use image node_id 2 for calling the ChannelReducer obj's underlying member method code with example usage: obj._apply_flat(cls, f, acts) and returns: new_flat, new_flat