class_docstr: It is a MongoDB based manager that help you to manage data, network architecture, parameters and logging.
  
  Parameters
  -------------
  ip : str
      Localhost or IP address.
  port : int
      Port number.
  dbname : str
      Database name.
  username : str or None
      User name, set to None if you do not need authentication.
  password : str
      Password.
  project_name : str or None
      Experiment key for this entire project, similar with the repository name of Github.
  
  Attributes
  ------------
  ip, port, dbname and other input parameters : see above
      See above.
  project_name : str
      The given project name, if no given, set to the script name.
  db : mongodb client
      See ``pymongo.MongoClient``.
class_docstr_tok: ["It","is","a","MongoDB","based","manager","that","help","you","to","manage","data",",","network","architecture",",","parameters","and","logging",".","Parameters","--","--","--","--","--","--","-","ip",":","str","Localhost","or","IP","address",".","port",":","int","Port","number",".","dbname",":","str","Database","name",".","username",":","str","or","None","User","name",",","set","to","None","if","you","do","not","need","authentication",".","password",":","str","Password",".","project_name",":","str","or","None","Experiment","key","for","this","entire","project",",","similar","with","the","repository","name","of","Github",".","Attributes","--","--","--","--","--","--","ip",",","port",",","dbname","and","other","input","parameters",":","see","above","See","above",".","project_name",":","str","The","given","project","name",",","if","no","given",",","set","to","the","script","name",".","db",":","mongodb","client","See","``","pymongo.MongoClient","``","."]
docstr: Save model architecture and parameters into database, timestamp will be added automatically.
  
  Parameters
  ----------
  network : TensorLayer Model
      TensorLayer Model instance.
  model_name : str
      The name/key of model.
  kwargs : other events
      Other events, such as name, accuracy, loss, step number and etc (optinal).
  
  Examples
  ---------
  Save model architecture and parameters into database.
  >>> db.save_model(net, accuracy=0.8, loss=2.3, name='second_model')
  
  Load one model with parameters from database (run this in other script)
  >>> net = db.find_top_model(accuracy=0.8, loss=2.3)
  
  Find and load the latest model.
  >>> net = db.find_top_model(sort=[("time", pymongo.DESCENDING)])
  >>> net = db.find_top_model(sort=[("time", -1)])
  
  Find and load the oldest model.
  >>> net = db.find_top_model(sort=[("time", pymongo.ASCENDING)])
  >>> net = db.find_top_model(sort=[("time", 1)])
  
  Get model information
  >>> net._accuracy
  ... 0.8
  
  Returns
  ---------
  boolean : True for success, False for fail.
docstr_tok: ["Save","model","architecture","and","parameters","into","database",",","timestamp","will","be","added","automatically",".","Parameters","--","--","--","--","--","network",":","TensorLayer","Model","TensorLayer","Model","instance",".","model_name",":","str","The","name\/key","of","model",".","kwargs",":","other","events","Other","events",",","such","as","name",",","accuracy",",","loss",",","step","number","and","etc","(","optinal",")",".","Examples","--","--","--","--","-","Save","model","architecture","and","parameters","into","database",".",">",">",">","db.save_model","(","net",",","accuracy=0.8",",","loss=2.3",",","name='second_model","'",")","Load","one","model","with","parameters","from","database","(","run","this","in","other","script",")",">",">",">","net","=","db.find_top_model","(","accuracy=0.8",",","loss=2.3",")","Find","and","load","the","latest","model",".",">",">",">","net","=","db.find_top_model","(","sort=","[","(","``","time","''",",","pymongo.DESCENDING",")","]",")",">",">",">","net","=","db.find_top_model","(","sort=","[","(","``","time","''",",","-1",")","]",")","Find","and","load","the","oldest","model",".",">",">",">","net","=","db.find_top_model","(","sort=","[","(","``","time","''",",","pymongo.ASCENDING",")","]",")",">",">",">","net","=","db.find_top_model","(","sort=","[","(","``","time","''",",","1",")","]",")","Get","model","information",">",">",">","net._accuracy","...","0.8","Returns","--","--","--","--","-","boolean",":","True","for","success",",","False","for","fail","."]
code: def save_model(self, network=None, model_name="model", **kwargs):
      """Save model architecture and parameters into database, timestamp will be added automatically.
  
      Parameters
      ----------
      network : TensorLayer Model
          TensorLayer Model instance.
      model_name : str
          The name/key of model.
      kwargs : other events
          Other events, such as name, accuracy, loss, step number and etc (optinal).
  
      Examples
      ---------
      Save model architecture and parameters into database.
      >>> db.save_model(net, accuracy=0.8, loss=2.3, name='second_model')
  
      Load one model with parameters from database (run this in other script)
      >>> net = db.find_top_model(accuracy=0.8, loss=2.3)
  
      Find and load the latest model.
      >>> net = db.find_top_model(sort=[("time", pymongo.DESCENDING)])
      >>> net = db.find_top_model(sort=[("time", -1)])
  
      Find and load the oldest model.
      >>> net = db.find_top_model(sort=[("time", pymongo.ASCENDING)])
      >>> net = db.find_top_model(sort=[("time", 1)])
  
      Get model information
      >>> net._accuracy
      ... 0.8
  
      Returns
      ---------
      boolean : True for success, False for fail.
      """
      kwargs.update({"model_name": model_name})
      self._fill_project_info(kwargs)  # put project_name into kwargs
  
      # params = network.get_all_params()
      params = network.all_weights
  
      s = time.time()
  
      # kwargs.update({'architecture': network.all_graphs, 'time': datetime.utcnow()})
      kwargs.update(
          {"architecture": network.config, "time": datetime.utcnow()}
      )
  
      try:
          params_id = self.model_fs.put(self._serialization(params))
          kwargs.update(
              {"params_id": params_id, "time": datetime.utcnow()}
          )
          self.db.Model.insert_one(kwargs)
          print(
              "[Database] Save model: SUCCESS, took: {}s".format(
                  round(time.time() - s, 2)
              )
          )
          return True
      except Exception as e:
          exc_type, exc_obj, exc_tb = sys.exc_info()
          fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
          logging.info(
              "{}  {}  {}  {}  {}".format(
                  exc_type, exc_obj, fname, exc_tb.tb_lineno, e
              )
          )
          print("[Database] Save model: FAIL")
          return False
  
imports: import os
  import pickle
  import sys
  import time
  from datetime import datetime
  import numpy
  import tensorflow
  import gridfs
  import pymongo
  from tensorlayer import logging
  from tensorlayer.files import assign_weights, del_folder, exists_or_mkdir, load_hdf5_to_weights, save_weights_to_hdf5, static_graph2net
label_desc: Use image node_id 6 for calling the TensorHub obj's underlying member method code with example usage: obj.save_model(network, model_name) and returns: True, False