本文整理汇总了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()
示例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)
示例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())
示例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"]
})
示例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")
示例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)
示例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']]
示例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']))
示例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
示例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)
示例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')
示例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()
示例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
示例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)))
示例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