当前位置: 首页>>代码示例>>Python>>正文


Python util.get_config方法代码示例

本文整理汇总了Python中util.get_config方法的典型用法代码示例。如果您正苦于以下问题:Python util.get_config方法的具体用法?Python util.get_config怎么用?Python util.get_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util的用法示例。


在下文中一共展示了util.get_config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: restore_best_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def restore_best_model(self):
    """Load bestmodel file from eval directory, add variables for adagrad, and save to train directory"""
    tf.logging.info("Restoring bestmodel for training...")

    # Initialize all vars in the model
    sess = tf.Session(config=util.get_config())
    print("Initializing all variables...")
    sess.run(tf.initialize_all_variables())

    # Restore the best model from eval dir
    saver = tf.train.Saver([v for v in tf.all_variables() if "Adagrad" not in v.name])
    print("Restoring all non-adagrad variables from best model in eval dir...")
    curr_ckpt = util.load_ckpt(saver, sess, "eval")
    print("Restored %s." % curr_ckpt)

    # Save this model to train dir and quit
    new_model_name = curr_ckpt.split("/")[-1].replace("bestmodel", "model")
    new_fname = os.path.join(FLAGS.log_root, "train", new_model_name)
    print("Saving model to %s..." % (new_fname))
    new_saver = tf.train.Saver() # this saver saves all variables that now exist, including Adagrad variables
    new_saver.save(sess, new_fname)
    print("Saved.")
    exit() 
开发者ID:yaserkl,项目名称:TransferRL,代码行数:25,代码来源:run_summarization.py

示例2: convert_to_coverage_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def convert_to_coverage_model(self):
    """Load non-coverage checkpoint, add initialized extra variables for coverage, and save as new checkpoint"""
    tf.logging.info("converting non-coverage model to coverage model..")

    # initialize an entire coverage model from scratch
    sess = tf.Session(config=util.get_config())
    print("initializing everything...")
    sess.run(tf.global_variables_initializer())

    # load all non-coverage weights from checkpoint
    saver = tf.train.Saver([v for v in tf.global_variables() if "coverage" not in v.name and "Adagrad" not in v.name])
    print("restoring non-coverage variables...")
    curr_ckpt = util.load_ckpt(saver, sess)
    print("restored.")

    # save this model and quit
    new_fname = curr_ckpt + '_cov_init'
    print("saving model to %s..." % (new_fname))
    new_saver = tf.train.Saver() # this one will save all variables that now exist
    new_saver.save(sess, new_fname)
    print("saved.")
    exit() 
开发者ID:yaserkl,项目名称:TransferRL,代码行数:24,代码来源:run_summarization.py

示例3: convert_to_reinforce_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def convert_to_reinforce_model(self):
    """Load non-reinforce checkpoint, add initialized extra variables for reinforce, and save as new checkpoint"""
    tf.logging.info("converting non-reinforce model to reinforce model..")

    # initialize an entire reinforce model from scratch
    sess = tf.Session(config=util.get_config())
    print("initializing everything...")
    sess.run(tf.global_variables_initializer())

    # load all non-reinforce weights from checkpoint
    saver = tf.train.Saver([v for v in tf.global_variables() if "reinforce" not in v.name and "Adagrad" not in v.name])
    print("restoring non-reinforce variables...")
    curr_ckpt = util.load_ckpt(saver, sess)
    print("restored.")

    # save this model and quit
    new_fname = curr_ckpt + '_rl_init'
    print("saving model to %s..." % (new_fname))
    new_saver = tf.train.Saver() # this one will save all variables that now exist
    new_saver.save(sess, new_fname)
    print("saved.")
    exit() 
开发者ID:yaserkl,项目名称:TransferRL,代码行数:24,代码来源:run_summarization.py

示例4: restore_best_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def restore_best_model():
    """Load bestmodel file from eval directory, add variables for adagrad, and save to train directory"""
    tf.logging.info("Restoring best model for training...")

    # Initialize all vars in the model
    sess = tf.Session(config=util.get_config())
    print("Initializing all variables...")
    sess.run(tf.initialize_all_variables())

    # Restore the best model from eval dir
    saver = tf.train.Saver([v for v in tf.all_variables() if "Adagrad" not in v.name])
    print("Restoring all non-adagrad variables from best model in eval dir...")
    curr_ckpt = util.load_ckpt(saver, sess, "eval")
    print("Restored %s." % curr_ckpt)

    # Save this model to train dir and quit
    new_model_name = curr_ckpt.split("/")[-1].replace("bestmodel", "model")
    new_fname = os.path.join(FLAGS.log_root, "train", new_model_name)
    print("Saving model to %s..." % new_fname)
    new_saver = tf.train.Saver()  # this saver saves all variables that now exist, including Adagrad variables
    new_saver.save(sess, new_fname)
    print("Saved.")
    exit() 
开发者ID:IBM,项目名称:MAX-Text-Summarizer,代码行数:25,代码来源:run_summarization.py

示例5: convert_to_coverage_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def convert_to_coverage_model():
    """Load non-coverage checkpoint, add initialized extra variables for coverage, and save as new checkpoint"""
    tf.logging.info("converting non-coverage model to coverage model..")

    # initialize an entire coverage model from scratch
    sess = tf.Session(config=util.get_config())
    print("initializing everything...")
    sess.run(tf.global_variables_initializer())

    # load all non-coverage weights from checkpoint
    saver = tf.train.Saver([v for v in tf.global_variables() if "coverage" not in v.name and "Adagrad" not in v.name])
    print("restoring non-coverage variables...")
    curr_ckpt = util.load_ckpt(saver, sess, FLAGS.ckpt_dir)
    print("restored.")

    # save this model and quit
    new_fname = curr_ckpt + '_cov_init'
    print("saving model to %s..." % new_fname)
    new_saver = tf.train.Saver()  # this one will save all variables that now exist
    new_saver.save(sess, new_fname)
    print("saved.")
    exit() 
开发者ID:IBM,项目名称:MAX-Text-Summarizer,代码行数:24,代码来源:run_summarization.py

示例6: convert_to_coverage_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def convert_to_coverage_model():
    """Load non-coverage checkpoint, add initialized extra variables for coverage, and save as new checkpoint"""
    tf.logging.info("converting non-coverage model to coverage model..")

    # initialize an entire coverage model from scratch
    sess = tf.Session(config=util.get_config())
    print("initializing everything...")
    sess.run(tf.global_variables_initializer())

    # load all non-coverage weights from checkpoint
    saver = tf.train.Saver([v for v in tf.global_variables(
    ) if "coverage" not in v.name and "Adagrad" not in v.name])
    print("restoring non-coverage variables...")
    curr_ckpt = util.load_ckpt(saver, sess)
    print("restored.")

    # save this model and quit
    new_fname = curr_ckpt + '_cov_init'
    print("saving model to %s..." % (new_fname))
    new_saver = tf.train.Saver()  # this one will save all variables that now exist
    new_saver.save(sess, new_fname)
    print("saved.")
    exit() 
开发者ID:rdangovs,项目名称:rotational-unit-of-memory,代码行数:25,代码来源:run_summarization.py

示例7: restore_best_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def restore_best_model():
  """Load bestmodel file from eval directory, add variables for adagrad, and save to train directory"""
  tf.logging.info("Restoring bestmodel for training...")

  # Initialize all vars in the model
  sess = tf.Session(config=util.get_config())
  print("Initializing all variables...")
  sess.run(tf.initialize_all_variables())

  # Restore the best model from eval dir
  saver = tf.train.Saver([v for v in tf.all_variables() if "Adagrad" not in v.name])
  print("Restoring all non-adagrad variables from best model in eval dir...")
  curr_ckpt = util.load_ckpt(saver, sess, "eval")
  print("Restored %s." % curr_ckpt)

  # Save this model to train dir and quit
  new_model_name = curr_ckpt.split("/")[-1].replace("bestmodel", "model")
  new_fname = os.path.join(FLAGS.log_root, "train", new_model_name)
  print("Saving model to %s..." % (new_fname))
  new_saver = tf.train.Saver() # this saver saves all variables that now exist, including Adagrad variables
  new_saver.save(sess, new_fname)
  print("Saved.")
  exit() 
开发者ID:armancohan,项目名称:long-summarization,代码行数:25,代码来源:run_summarization.py

示例8: convert_linear_attn_to_hier_model

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def convert_linear_attn_to_hier_model():
    """Load non-coverage checkpoint, add initialized extra variables for coverage, and save as new checkpoint"""
    tf.logging.info("converting linear model to hier model..")

    # initialize an entire coverage model from scratch
    sess = tf.Session(config=util.get_config())
    print("initializing everything...")
    sess.run(tf.global_variables_initializer())

    # load all non-coverage weights from checkpoint
    saver = tf.train.Saver([v for v in tf.global_variables(
    ) if "Linear--Section-Features" not in v.name and "v_sec" not in v.name and "Adagrad" not in v.name])
    print("restoring variables...")
    curr_ckpt = util.load_ckpt(saver, sess)
    print("restored.")

    # save this model and quit
    new_fname = curr_ckpt
    print(("saving model to %s..." % (new_fname)))
    new_saver = tf.train.Saver()  # this one will save all variables that now exist
    new_saver.save(sess, new_fname)
    print("saved.")
    exit() 
开发者ID:armancohan,项目名称:long-summarization,代码行数:25,代码来源:run_summarization.py

示例9: setup_training_generator

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def setup_training_generator(model):
  """Does setup before starting training (run_training)"""
  train_dir = os.path.join(FLAGS.log_root, "train-generator")
  if not os.path.exists(train_dir): os.makedirs(train_dir)

  model.build_graph() # build the graph

  saver = tf.train.Saver(max_to_keep=20)  # we use this to load checkpoints for decoding
  sess = tf.Session(config=util.get_config())
  #sess.run(tf.train.Saver(max_to_keep=20))
  #init = tf.global_variables_initializer()
  #sess.run(init)

  # Load an initial checkpoint to use for decoding
  util.load_ckpt(saver, sess, ckpt_dir="train-generator")


  return sess, saver,train_dir 
开发者ID:loretoparisi,项目名称:docker,代码行数:20,代码来源:main.py

示例10: setup_training_discriminator

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def setup_training_discriminator(model):
    """Does setup before starting training (run_training)"""
    train_dir = os.path.join(FLAGS.log_root, "train-discriminator")
    if not os.path.exists(train_dir): os.makedirs(train_dir)

    model.build_graph()  # build the graph

    saver = tf.train.Saver(max_to_keep=20)  # we use this to load checkpoints for decoding
    sess = tf.Session(config=util.get_config())
    #init = tf.global_variables_initializer()
    #sess.run(init)
    util.load_ckpt(saver, sess, ckpt_dir="train-discriminator")



    return sess, saver,train_dir 
开发者ID:loretoparisi,项目名称:docker,代码行数:18,代码来源:main.py

示例11: init_cmdb

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def init_cmdb():
    try:
        # 取host (在cmdb_host表里)
        # fields = ['id', 'hostname', 'ip', 'vm_status', 'st', 'uuid', 'manufacturers', 'server_type', 'server_cpu', 'os',
        #           'server_disk', 'server_mem', 'mac_address', 'manufacture_date', 'check_update_time', 'server_purpose',
        #           'server_run', 'expire', 'server_up_time']
        fields = ['id','hostname','ip']

        # 将角色对应的p_id都转为name,最终返回的结果p_id的值都是name
        hosts = db.Cursor(util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                                          'api')).get_results('cmdb_host', fields)
        for h in hosts:
            data = {'cmdb_hostid': h['id']}
            where = {'ip': h['ip']}
            result = db.Cursor(
                util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                                'api')).execute_update_sql('zbhost', data, where)
    # 更新到cache表, ip
    except:
        return "" 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:22,代码来源:zabbix_api.py

示例12: init_zabbix

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def init_zabbix():
    try:
        # 第一步 取出所有host,要ip,host,id
        # zb_hosts = app.config['zabbix'].get_hosts()
        zb_hosts = zabbix_api.Zabbix(
            util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                            'zabbix')).get_hosts()
        zb_hosts_interface = zabbix_api.Zabbix(
            util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                            'zabbix')).get_interface([z['hostid'] for z in zb_hosts])
        data = []
        ret = []
        for h in zb_hosts:
            h['ip'] = zb_hosts_interface[h['hostid']]
            data.append(h)
            ###数据插入数据库
        for i in data:
            result = db.Cursor(
                util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                                'api')).execute_insert_sql('zbhost', i)

    except:
        return "" 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:25,代码来源:zabbix_api.py

示例13: create_zabbix_host

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def create_zabbix_host(hostid, groupid):
        ret = []
        for host in hostid:
            data = {
                "host": host,
                "interfaces": [
                    {
                        "type": 1,
                        "main": 1,
                        "useip": 1,
                        "ip": host,
                        "dns": "",
                        "port": "10050"
                    }
                ],
                "groups": [
                    {
                        "groupid": groupid
                    }
                ]
            }
            ret.append(zabbix_api.Zabbix(
            util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                            'zabbix')).create_host(data))
        return ret 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:27,代码来源:zabbix_api.py

示例14: create_maintenance

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def create_maintenance(name, start, stop, hostids, time):
        data = {
            "name": name,
            "active_since": start,
            "active_till": stop,
            "hostids": hostids,
            "timeperiods": [
                {
                    "timeperiod_type": 0,
                    "period": time
                }
            ]
        }
        ret = zabbix_api.Zabbix(
            util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),
                            'zabbix')).create_maintenance(data)
        return ret 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:19,代码来源:zabbix_api.py

示例15: zbhost_select

# 需要导入模块: import util [as 别名]
# 或者: from util import get_config [as 别名]
def zbhost_select(request):
    datadict = {}
    ret = []

    # zbhost表关联cmdb_host by zhoux
    init()
    # update by zhouzx (delete 字段 host)
    fields = ['id', 'cmdb_hostid', 'hostid', 'host', 'ip']
    zabbix_hosts = db.Cursor(util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),'api')).get_results('zbhost', fields)
    hostid = [str(zb["cmdb_hostid"]) for zb in zabbix_hosts]
    server_hosts = db.Cursor(util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),'api')).get_results('cmdb_host', ["id"])
    for i in server_hosts:
        if str(i["id"]) not in hostid:
            datadict["id"] = i["id"]
            # all_host = app.config['cursor'].get_results('cmdb_host',["ip"],datadict)
            get_ip = db.Cursor(util.get_config(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'service.conf'),'api')).get_where_results('cmdb_host', ["id", "ip"], datadict)
            ret.append(get_ip[0])



    return json.dumps({'code': 0, 'result': ret}) 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:23,代码来源:views.py


注:本文中的util.get_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。