class_docstr: Class which stores a list of layers describing the model. Can train the layer
  weights on a dataset, evaluate on a test set and serialize the model.
  Additional functionality can be added to the fit method through callback functions.
  
  Arguments:
      layers: layer container, a list of layers (that will be containerized),
              or a serialized model description
      dataset (NervanaDataIterator): Data set (ignored, will be removed)
      weights_only (bool): set to True if you do not want to recreate layers
                           and states during deserialization from a serialized model
                           description.  Defaults to False.
      name (str): Model name.  Defaults to "model"
      optimizer (Optimizer): Optimizer object which defines the learning rule for updating
                             model parameters (i.e., GradientDescentMomentum, Adadelta)
class_docstr_tok: ["Class","which","stores","a","list","of","layers","describing","the","model",".","Can","train","the","layer","weights","on","a","dataset",",","evaluate","on","a","test","set","and","serialize","the","model",".","Additional","functionality","can","be","added","to","the","fit","method","through","callback","functions",".","Arguments",":","layers",":","layer","container",",","a","list","of","layers","(","that","will","be","containerized",")",",","or","a","serialized","model","description","dataset","(","NervanaDataIterator",")",":","Data","set","(","ignored",",","will","be","removed",")","weights_only","(","bool",")",":","set","to","True","if","you","do","not","want","to","recreate","layers","and","states","during","deserialization","from","a","serialized","model","description",".","Defaults","to","False",".","name","(","str",")",":","Model","name",".","Defaults","to","``","model","''","optimizer","(","Optimizer",")",":","Optimizer","object","which","defines","the","learning","rule","for","updating","model","parameters","(","i.e.",",","GradientDescentMomentum",",","Adadelta",")"]
docstr: Creates a dictionary storing the layer parameters and epochs complete.
  
  Arguments:
      fn (str): file to save pkl formatted model dictionary
      keep_states (bool): Whether to save optimizer states.
  
  Returns:
      dict: Model data including layer parameters and epochs complete.
docstr_tok: ["Creates","a","dictionary","storing","the","layer","parameters","and","epochs","complete",".","Arguments",":","fn","(","str",")",":","file","to","save","pkl","formatted","model","dictionary","keep_states","(","bool",")",":","Whether","to","save","optimizer","states",".","Returns",":","dict",":","Model","data","including","layer","parameters","and","epochs","complete","."]
code: def serialize(self, fn=None, keep_states=True):
      """
      Creates a dictionary storing the layer parameters and epochs complete.
  
      Arguments:
          fn (str): file to save pkl formatted model dictionary
          keep_states (bool): Whether to save optimizer states.
  
      Returns:
          dict: Model data including layer parameters and epochs complete.
      """
  
      # get the model dict with the weights
      pdict = self.get_description(
          get_weights=True, keep_states=keep_states
      )
      pdict["epoch_index"] = self.epoch_index + 1
      if self.initialized:
          if not hasattr(self.layers, "decoder"):
              pdict["train_input_shape"] = self.layers.in_shape
          else:
              # serialize shapes both for encoder and decoder
              pdict["train_input_shape"] = (
                  self.layers.encoder.in_shape
                  + self.layers.decoder.in_shape
              )
      if fn is not None:
          save_obj(pdict, fn)
          return
      return pdict
  
imports: from __future__ import division, print_function
  from builtins import str, zip
  from collections import OrderedDict
  import logging
  from neon import __version__
  from neon import NervanaObject, logger
  from neon.backends.backend import Block
  from neon.transforms import CrossEntropyBinary, Logistic
  from neon.util.persist import load_obj, save_obj, load_class
  from neon.util.modeldesc import ModelDescription
  from neon.layers import Sequential, Activation
  from neon.layers.container import DeltasTree, SkipThought
  from neon.util.beamsearch import BeamSearch
  from neon.optimizers.optimizer import get_param_list
  import numpy
label_desc: Use image node_id 19 for calling the Model obj's underlying member method code with example usage: obj.serialize(fn, keep_states) and returns: pdict