當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。