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


Python config.get_config方法代码示例

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


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

示例1: main

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def main(_):
  gpu_options = tf.GPUOptions(
      per_process_gpu_memory_fraction=calc_gpu_fraction(FLAGS.gpu_fraction))

  with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
    config = get_config(FLAGS) or FLAGS

    if config.env_type == 'simple':
      env = SimpleGymEnvironment(config)
    else:
      env = GymEnvironment(config)

    if not tf.test.is_gpu_available() and FLAGS.use_gpu:
      raise Exception("use_gpu flag is true when no GPUs are available")

    if not FLAGS.use_gpu:
      config.cnn_format = 'NHWC'

    agent = Agent(config, env, sess)

    if FLAGS.is_train:
      agent.train()
    else:
      agent.play() 
开发者ID:devsisters,项目名称:DQN-tensorflow,代码行数:26,代码来源:main.py

示例2: init

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def init(browser_type):
    """ Initialize the uwsgi worker which will read urls to archive from redis queue
    and use associated web driver to connect to remote web browser
    """
    logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s',
                        level=logging.DEBUG)
    logging.debug('WebDriver Worker Started')

    config = get_config()

    archives = config['archives']

    rc = init_redis(config)

    browser = get_avail_browser(config, rc, browser_type)

    run(rc, browser, archives, config, browser_type) 
开发者ID:ikreymer,项目名称:browsertrix,代码行数:19,代码来源:worker.py

示例3: test

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def test(self):
    from torch.utils.data import DataLoader
    from lib.utils import Timer
    from config import get_config
    config = get_config()

    dataset = SynthiaVoxelizationDataset(config)
    timer = Timer()

    data_loader = DataLoader(
        dataset=dataset,
        collate_fn=cfl_collate_fn_factory(limit_numpoints=False),
        num_workers=0,
        batch_size=4,
        shuffle=True)

    # Start from index 1
    # for i, batch in enumerate(data_loader, 1):
    iter = data_loader.__iter__()
    for i in range(100):
      timer.tic()
      batch = iter.next()
      print(batch, timer.toc()) 
开发者ID:chrischoy,项目名称:SpatioTemporalSegmentation,代码行数:25,代码来源:synthia.py

示例4: add_towel_mode

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def add_towel_mode(upd: Updater, handlers_group: int):
    logger.info("registering towel-mode handlers")
    dp = upd.dispatcher

    # catch all new users and drop the towel
    dp.add_handler(MessageHandler(Filters.status_update.new_chat_members, catch_new_user),
                   handlers_group)

    # check for reply or remove messages
    dp.add_handler(MessageHandler(
        Filters.group & ~Filters.status_update, catch_reply),
        handlers_group
    )

    # "i am a bot button"
    dp.add_handler(CallbackQueryHandler(i_am_a_bot_btn), handlers_group)

    # ban quarantine users, if time is gone
    upd.job_queue.run_repeating(ban_user, interval=60, first=60, context={
        "chat_id": get_config()["GROUP_CHAT_ID"]
    }) 
开发者ID:egregors,项目名称:vldc-bot,代码行数:23,代码来源:towel_mode.py

示例5: destalinate_job

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def destalinate_job():
    raven_client = RavenClient()

    logging.info("Destalinating")
    if not get_config().sb_token or not get_config().api_token:
        logging.error(
            "Missing at least one required Slack environment variable.\n"
            "Make sure to set DESTALINATOR_SB_TOKEN and DESTALINATOR_API_TOKEN."
        )
    else:
        try:
            archiver.Archiver().archive()
            warner.Warner().warn()
            announcer.Announcer().announce()
            flagger.Flagger().flag()
            logging.info("OK: destalinated")
        except Exception as e:  # pylint: disable=W0703
            raven_client.captureException()
            if not get_config().sentry_dsn:
                raise e
    logging.info("END: destalinate_job") 
开发者ID:randsleadershipslack,项目名称:destalinator,代码行数:23,代码来源:scheduler.py

示例6: get_model

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def get_model(config=None):
    if not None:
        config, unparsed = get_config()
    return get_trainer(config) 
开发者ID:mkocaoglu,项目名称:CausalGAN,代码行数:6,代码来源:main.py

示例7: connect

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def connect(self):
    config = get_config()

    self.client = MongoClient(config['db.dsn'])
    self.db = self.client[config['db.database']] 
开发者ID:itspoma,项目名称:audio-fingerprint-identifying-python,代码行数:7,代码来源:db_mongo.py

示例8: connect

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def connect(self):
    config = get_config()

    self.conn = sqlite3.connect(config['db.file'])
    self.conn.text_factory = str

    self.cur = self.conn.cursor()

    print(colored('sqlite - connection opened','white',attrs=['dark'])) 
开发者ID:itspoma,项目名称:audio-fingerprint-identifying-python,代码行数:11,代码来源:db_sqlite.py

示例9: init

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def init():
    """ Init the application and add routes """

    logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s',
                        level=logging.DEBUG)

    global theconfig
    theconfig = get_config()

    global rc
    rc = init_redis(theconfig)

    app = default_app()

    return app 
开发者ID:ikreymer,项目名称:browsertrix,代码行数:17,代码来源:app.py

示例10: test_get_config

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def test_get_config(self):
        c: Dict = get_config()
        self.assertEqual(c["DEBUG"], self.env_debug)
        self.assertEqual(c["GROUP_CHAT_ID"], self.env_chat_id)
        self.assertEqual(c["TOKEN"], self.env_token)
        self.assertEqual(c["MONGO_USER"], self.env_mongo_initdb_root_username)
        self.assertEqual(c["MONGO_PASS"], self.env_mongo_initdb_root_password) 
开发者ID:egregors,项目名称:vldc-bot,代码行数:9,代码来源:get_conf_from_env_test.py

示例11: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def __init__(self, satoshis=0):
        super(Amount, self).__init__()
        self.satoshis = satoshis
        self.config = config.get_config()
        self.fmt = self.config.get_option('amount_format', 'satoshis') 
开发者ID:mazaclub,项目名称:hashmal,代码行数:7,代码来源:gui_utils.py

示例12: main

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def main(_):
    with tf.Session() as sess:
        config = get_config(FLAGS)
        env = MyEnvironment(config)
        agent = Agent(config, env, sess)

        if FLAGS.is_train:
            agent.train()
        else:
            if FLAGS.dataset == 'mine':
                agent.play_mine()
            else:
                agent.play() 
开发者ID:yuke93,项目名称:RL-Restore,代码行数:15,代码来源:main.py

示例13: predictByPart

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def predictByPart(data, peaks):
    classesM = ['N','Ventricular','Paced','A','F','Noise']#,'L','R','f','j','E','a','J','Q','e','S']
    predicted = list()
    result = ""
    counter = [0]* len(classesM)
    from keras.models import load_model
    model = load_model('models/MLII-latest.hdf5')
    config = get_config() 
    for i, peak in enumerate(peaks[3:-1]):
      total_n =len(peaks)
      start, end =  peak-config.input_size//2 , peak+config.input_size//2
      prob = model.predict(data[:, start:end])
      prob = prob[:,0]
      ann = np.argmax(prob)
      counter[ann]+=1
      if classesM[ann] != "N":
        print("The {}/{}-record classified as {} with {:3.1f}% certainty".format(i,total_n,classesM[ann],100*prob[0,ann]))
      result += "("+ classesM[ann] +":" + str(round(100*prob[0,ann],1)) + "%)"
      predicted.append([classesM[ann],prob])
      if classesM[ann] != 'N' and prob[0,ann] > 0.95:
        import matplotlib.pyplot as plt
        plt.plot(data[:, start:end][0,:,0],)
        mkdir_recursive('results')
        plt.savefig('results/hazard-'+classesM[ann]+'.png', format="png", dpi = 300)
        plt.close()
    result += "{}-N, {}-Venticular, {}-Paced, {}-A, {}-F, {}-Noise".format(counter[0], counter[1], counter[2], counter[3], counter[4], counter[5])
    return predicted, result 
开发者ID:physhik,项目名称:ecg-mit-bih,代码行数:29,代码来源:predict.py

示例14: main

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def main():
    testing_file = "./new_data/test.ann.json"
    trained_model = "./checkpoints/model.ckpt"
    embedding_file = "D:/DataMining/QASystem/wiki/wiki.zh.text.vector"
    # embedding_file = "./wiki.zh.text.vector"
    embedding_size = 60  # Word embedding dimension
    batch_size = 64  # Batch data size
    sequence_length = 150  # Sentence length
    learning_rate = 0.01
    gpu_mem_usage = 0.75
    gpu_device = "/gpu:0"
    cpu_device = "/cpu:0"

    config = get_config()  # Not used yet
    embeddings, word2idx = load_embedding(embedding_file)
    questions, evidences, y1, y2 = load_data(testing_file, word2idx, sequence_length)
    with tf.Graph().as_default(), tf.device(gpu_device):
        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_mem_usage)
        session_conf = tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options)
        with tf.variable_scope('Model'):
            model = DGCNN(config, embeddings, sequence_length, embedding_size)
            with tf.Session(config=session_conf).as_default() as sess:
                saver = tf.train.Saver()
                print("Start loading the model")
                saver.restore(sess, trained_model)
                print("The model is loaded")
                acc1, acc2 = [], []
                for batch_questions, batch_evidences, batch_y1, batch_y2 in next_batch(questions, evidences, y1, y2, batch_size):
                    feed_dict = {
                        model.e: batch_evidences,
                        model.q: batch_questions,
                        model.y1: batch_y1,
                        model.y2: batch_y2,
                        model.is_train: False
                    }
                    acc1_, acc2_ = sess.run([model.acc1, model.acc2], feed_dict)
                    acc1.append(acc1_)
                    acc2.append(acc2_)
                    print('Acc1 %2.3f\tAcc2 %2.3f' % (acc1_, acc2_))
                print('Average: Acc1 %2.3f\tAcc2 %2.3f' % (np.mean(acc1), np.mean(acc2))) 
开发者ID:Chiang97912,项目名称:DGCNN,代码行数:42,代码来源:test.py

示例15: main

# 需要导入模块: import config [as 别名]
# 或者: from config import get_config [as 别名]
def main ():
    # parse configuration
    config, _ = get_config()
    # set visible GPUs
    os.environ['CUDA_VISIBLE_DEVICES'] = config.gpu

    if config.test:
        run_test (config)
    else:
        run_train (config)
    # end of main 
开发者ID:TAMU-VITA,项目名称:ALISTA,代码行数:13,代码来源:main.py


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