class_docstr: Defines the configuration and handles the conversion and mutation of
  individual genomes. Should be created and passed to a `DEvol` instance.
  
  ---
  Genomes are represented as fixed-with lists of integers corresponding
  to sequential layers and properties. A model with 2 convolutional layers
  and 1 dense layer would look like:
  
  [<conv layer><conv layer><dense layer><optimizer>]
  
  The makeup of the convolutional layers and dense layers is defined in the
  GenomeHandler below under self.convolutional_layer_shape and
  self.dense_layer_shape. <optimizer> consists of just one property.
class_docstr_tok: ["Defines","the","configuration","and","handles","the","conversion","and","mutation","of","individual","genomes",".","Should","be","created","and","passed","to","a","`","DEvol","`","instance",".","--","-","Genomes","are","represented","as","fixed-with","lists","of","integers","corresponding","to","sequential","layers","and","properties",".","A","model","with","2","convolutional","layers","and","1","dense","layer","would","look","like",":","[","<","conv","layer",">","<","conv","layer",">","<","dense","layer",">","<","optimizer",">","]","The","makeup","of","the","convolutional","layers","and","dense","layers","is","defined","in","the","GenomeHandler","below","under","self.convolutional_layer_shape","and","self.dense_layer_shape",".","<","optimizer",">","consists","of","just","one","property","."]
docstr: Creates a GenomeHandler according
  
  Args:
      max_conv_layers: The maximum number of convolutional layers
      max_dense_layers: The maximum number of dense (fully connected)
              layers, including output layer
      max_filters: The maximum number of conv filters (feature maps) in a
              convolutional layer
      max_dense_nodes: The maximum number of nodes in a dense layer
      input_shape: The shape of the input
      n_classes: The number of classes
      batch_normalization (bool): whether the GP should include batch norm
      dropout (bool): whether the GP should include dropout
      max_pooling (bool): whether the GP should include max pooling layers
      optimizers (list): list of optimizers to be tried by the GP. By
              default, the network uses Keras's built-in adam, rmsprop,
              adagrad, and adadelta
      activations (list): list of activation functions to be tried by the
              GP. By default, relu and sigmoid.
docstr_tok: ["Creates","a","GenomeHandler","according","Args",":","max_conv_layers",":","The","maximum","number","of","convolutional","layers","max_dense_layers",":","The","maximum","number","of","dense","(","fully","connected",")","layers",",","including","output","layer","max_filters",":","The","maximum","number","of","conv","filters","(","feature","maps",")","in","a","convolutional","layer","max_dense_nodes",":","The","maximum","number","of","nodes","in","a","dense","layer","input_shape",":","The","shape","of","the","input","n_classes",":","The","number","of","classes","batch_normalization","(","bool",")",":","whether","the","GP","should","include","batch","norm","dropout","(","bool",")",":","whether","the","GP","should","include","dropout","max_pooling","(","bool",")",":","whether","the","GP","should","include","max","pooling","layers","optimizers","(","list",")",":","list","of","optimizers","to","be","tried","by","the","GP",".","By","default",",","the","network","uses","Keras","'s","built-in","adam",",","rmsprop",",","adagrad",",","and","adadelta","activations","(","list",")",":","list","of","activation","functions","to","be","tried","by","the","GP",".","By","default",",","relu","and","sigmoid","."]
code: def __init__(
      self,
      max_conv_layers,
      max_dense_layers,
      max_filters,
      max_dense_nodes,
      input_shape,
      n_classes,
      batch_normalization=True,
      dropout=True,
      max_pooling=True,
      optimizers=None,
      activations=None,
  ):
      """
      Creates a GenomeHandler according
  
      Args:
          max_conv_layers: The maximum number of convolutional layers
          max_dense_layers: The maximum number of dense (fully connected)
                  layers, including output layer
          max_filters: The maximum number of conv filters (feature maps) in a
                  convolutional layer
          max_dense_nodes: The maximum number of nodes in a dense layer
          input_shape: The shape of the input
          n_classes: The number of classes
          batch_normalization (bool): whether the GP should include batch norm
          dropout (bool): whether the GP should include dropout
          max_pooling (bool): whether the GP should include max pooling layers
          optimizers (list): list of optimizers to be tried by the GP. By
                  default, the network uses Keras's built-in adam, rmsprop,
                  adagrad, and adadelta
          activations (list): list of activation functions to be tried by the
                  GP. By default, relu and sigmoid.
      """
      if max_dense_layers < 1:
          raise ValueError(
              "At least one dense layer is required for softmax layer"
          )
      if max_filters > 0:
          filter_range_max = int(math.log(max_filters, 2)) + 1
      else:
          filter_range_max = 0
      self.optimizer = optimizers or [
          "adam",
          "rmsprop",
          "adagrad",
          "adadelta",
      ]
      self.activation = activations or [
          "relu",
          "sigmoid",
      ]
      self.convolutional_layer_shape = [
          "active",
          "num filters",
          "batch normalization",
          "activation",
          "dropout",
          "max pooling",
      ]
      self.dense_layer_shape = [
          "active",
          "num nodes",
          "batch normalization",
          "activation",
          "dropout",
      ]
      self.layer_params = {
          "active": [0, 1],
          "num filters": [2**i for i in range(3, filter_range_max)],
          "num nodes": [
              2**i
              for i in range(4, int(math.log(max_dense_nodes, 2)) + 1)
          ],
          "batch normalization": [0, (1 if batch_normalization else 0)],
          "activation": list(range(len(self.activation))),
          "dropout": [(i if dropout else 0) for i in range(11)],
          "max pooling": list(range(3)) if max_pooling else 0,
      }
  
      self.convolution_layers = max_conv_layers
      self.convolution_layer_size = len(self.convolutional_layer_shape)
      self.dense_layers = (
          max_dense_layers - 1
      )  # this doesn't include the softmax layer, so -1
      self.dense_layer_size = len(self.dense_layer_shape)
      self.input_shape = input_shape
      self.n_classes = n_classes
  
file_path: devol/devol/genome_handler.py
imports: import numpy
  import random
  import math
  from keras.models import Sequential
  from keras.layers import Activation, Dense, Dropout, Flatten
  from keras.layers.convolutional import Convolution2D, MaxPooling2D
  from keras.layers.normalization import BatchNormalization
label_desc: Use image node_id 1 to create a new GenomeHandler object  with example: obj = GenomeHandler(max_conv_layers, max_dense_layers, max_filters, max_dense_nodes, input_shape, n_classes, batch_normalization, dropout, max_pooling, optimizers, activations)