class_docstr: A class for modifying a neural nework using many of the operations above. 
class_docstr_tok: ["A","class","for","modifying","a","neural","nework","using","many","of","the","operations","above","."]
docstr: Returns a list of new neural networks which have undergone a single modification
  from nn. 
docstr_tok: ["Returns","a","list","of","new","neural","networks","which","have","undergone","a","single","modification","from","nn","."]
code: def get_single_step_modifications(
      self, nn, num_single_step_modifications="all", **kwargs
  ):
      """Returns a list of new neural networks which have undergone a single modification
      from nn."""
      (
          prims_by_type,
          type_prob_masses,
      ) = self.get_primitives_grouped_by_type(nn, **kwargs)
      groups = list(prims_by_type.keys())
      if num_single_step_modifications == "all":
          prims_by_group = prims_by_type.values()
          modifiers = [
              elem
              for group_prims in prims_by_group
              for elem in group_prims
          ]
          num_single_step_modifications = len(modifiers)
      else:
          prob_masses = np.array(
              [type_prob_masses[key] for key in groups]
          )
          prob_masses = prob_masses / prob_masses.sum()
          modif_groups = np.random.choice(
              groups,
              max(2 * num_single_step_modifications, 20),
              p=prob_masses,
          )
          # Shuffle each list
          for grp in groups:
              np.random.shuffle(prims_by_type[grp])
          # Now create a list of modifiers
          modifiers = []
          for grp in modif_groups:
              if len(prims_by_type[grp]) == 0:
                  continue
              else:
                  modifiers.append(prims_by_type[grp].pop())
      # Now go through each modifier and make changes.
      ret = []
      for modif in modifiers:
          curr_val = modif(nn)
          if self._is_a_valid_network(curr_val):
              ret.append(curr_val)
              if len(ret) >= num_single_step_modifications:
                  break
      if len(ret) < 0.25 * num_single_step_modifications:
          self.reporter.writeln(
              (
                  "Consider reducing constraints. %d/%d modifications "
                  + "accepted."
              )
              % (len(ret), num_single_step_modifications)
          )
      return ret
  
imports: from argparse import Namespace
  from copy import deepcopy
  import numpy
  from .neural_network import ConvNeuralNetwork, MultiLayerPerceptron, MLP_RECTIFIERS, MLP_SIGMOIDS, is_a_pooling_layer_label, is_a_conv_layer_label, CNNImageSizeMismatchException, CNNNoConvAfterIPException
  from ..utils.general_utils import reorder_list_or_array, reorder_rows_and_cols_in_matrix
  from ..utils.option_handler import get_option_specs, load_options
  from ..utils.reporters import get_reporter
label_desc: Use image node_id 7 for calling the NNModifier obj's underlying member method code with example usage: obj.get_single_step_modifications(nn, num_single_step_modifications) and returns: ret