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


Python utils.get_logger方法代码示例

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


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

示例1: __init__

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def __init__(self, batch_size, epoch_num, hidden_dim, embeddings,
                 dropout_keep, optimizer, lr, clip_grad,
                 tag2label, vocab, shuffle,
                 model_path, summary_path, log_path, result_path,
                 CRF=True, update_embedding=True):
        self.batch_size = batch_size
        self.epoch_num = epoch_num
        self.hidden_dim = hidden_dim
        self.embeddings = embeddings
        self.dropout_keep_prob = dropout_keep
        self.optimizer = optimizer
        self.lr = lr
        self.clip_grad = clip_grad
        self.tag2label = tag2label
        self.num_tags = len(tag2label)
        self.vocab = vocab  # word2id
        self.shuffle = shuffle
        self.model_path = model_path
        self.summary_path = summary_path
        self.logger = get_logger(log_path)
        self.result_path = result_path
        self.CRF = CRF
        self.update_embedding = update_embedding 
开发者ID:baiyyang,项目名称:medical-entity-recognition,代码行数:25,代码来源:model.py

示例2: _initialize_config

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def _initialize_config(self):
        # create folders and logger
        if not os.path.exists(self.cfg["checkpoint_path"]):
            os.makedirs(self.cfg["checkpoint_path"])
        if not os.path.exists(self.cfg["summary_path"]):
            os.makedirs(self.cfg["summary_path"])
        self.logger = get_logger(os.path.join(self.cfg["checkpoint_path"], "log.txt"))
        # load dictionary
        dict_data = load_dataset(self.cfg["vocab"])
        self.word_dict, self.char_dict = dict_data["word_dict"], dict_data["char_dict"]
        self.tag_dict = dict_data["tag_dict"]
        del dict_data
        self.word_vocab_size = len(self.word_dict)
        self.char_vocab_size = len(self.char_dict)
        self.tag_vocab_size = len(self.tag_dict)
        self.rev_word_dict = dict([(idx, word) for word, idx in self.word_dict.items()])
        self.rev_char_dict = dict([(idx, char) for char, idx in self.char_dict.items()])
        self.rev_tag_dict = dict([(idx, tag) for tag, idx in self.tag_dict.items()]) 
开发者ID:IsaacChanghau,项目名称:neural_sequence_labeling,代码行数:20,代码来源:base_model.py

示例3: evaluate_line

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def evaluate_line():
    config = load_config(FLAGS.config_file)
    logger = get_logger(FLAGS.log_file)
    # limit GPU memory
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True
    with open(FLAGS.map_file, "rb") as f:
        char_to_id, id_to_char, tag_to_id, id_to_tag = pickle.load(f)
    with tf.Session(config=tf_config) as sess:
        model = create_model(sess, Model, FLAGS.ckpt_path, load_word2vec, config, id_to_char, logger, False)
        while True:
            # try:
            #     line = input("请输入测试句子:")
            #     result = ckpt.evaluate_line(sess, input_from_line(line, char_to_id), id_to_tag)
            #     print(result)
            # except Exception as e:
            #     logger.info(e)

            line = input("请输入测试句子:")
            result = model.evaluate_line(sess, input_from_line(line, char_to_id), id_to_tag)
            print(result) 
开发者ID:sliderSun,项目名称:pynlp,代码行数:23,代码来源:main.py

示例4: make_path_preparations

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def make_path_preparations(args):
    seed = hash(str(args)) % 1000_000
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    random.seed(seed)

    # logger path
    args_hash = str(hash(str(args)))
    if not os.path.exists(args.logs_path):
        os.makedirs(args.logs_path)
    logger = get_logger(f"{args.logs_path}/l{args_hash}.log")
    print(f"{args.logs_path}/l{args_hash}.log")
    logger.info(f"args: {str(args)}")
    logger.info(f"args hash: {args_hash}")
    logger.info(f"random seed: {seed}")

    # model path
    args.model_dir = f"{args.model_dir}/m{args_hash}"
    if not os.path.exists(args.model_dir):
        os.makedirs(args.model_dir)
    logger.info(f"checkpoint's dir is: {args.model_dir}")

    # tensorboard path
    tensorboard_path = f"{args.tensorboard_path}/t{args_hash}"
    if not os.path.exists(tensorboard_path):
        os.makedirs(tensorboard_path)
    summary_writer = dict()
    summary_writer["train"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'train'))
    summary_writer["valid"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'valid'))

    return logger, summary_writer 
开发者ID:facebookresearch,项目名称:latent-treelstm,代码行数:33,代码来源:train_ppo_model.py

示例5: make_path_preparations

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def make_path_preparations(args):
    seed = hash(str(args)) % 1000_000
    ListOpsBucketSampler.random_seed = seed
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    random.seed(seed)

    # logger path
    args_hash = str(hash(str(args)))
    if not os.path.exists(args.logs_path):
        os.makedirs(args.logs_path)
    logger = get_logger(f"{args.logs_path}/l{args_hash}.log")
    print(f"{args.logs_path}/l{args_hash}.log")
    logger.info(f"args: {str(args)}")
    logger.info(f"args hash: {args_hash}")
    logger.info(f"random seed: {seed}")

    # model path
    args.model_dir = f"{args.model_dir}/m{args_hash}"
    if not os.path.exists(args.model_dir):
        os.makedirs(args.model_dir)
    logger.info(f"checkpoint's dir is: {args.model_dir}")

    # tensorboard path
    tensorboard_path = f"{args.tensorboard_path}/t{args_hash}"
    if not os.path.exists(tensorboard_path):
        os.makedirs(tensorboard_path)
    summary_writer = dict()
    summary_writer["train"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'train'))
    summary_writer["valid"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'valid'))

    return logger, summary_writer 
开发者ID:facebookresearch,项目名称:latent-treelstm,代码行数:34,代码来源:train_ppo_model.py

示例6: make_path_preparations

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def make_path_preparations(args):
    # TODO
    seed = 42
    # seed = hash(str(args)) % 1000_000
    ListOpsBucketSampler.random_seed = seed
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    random.seed(seed)

    # logger path
    args_hash = str(hash(str(args)))
    if not os.path.exists(args.logs_path):
        os.makedirs(args.logs_path)
    logger = get_logger(f"{args.logs_path}/l{args_hash}.log")
    print(f"{args.logs_path}/l{args_hash}.log")
    logger.info(f"args: {str(args)}")
    logger.info(f"args hash: {args_hash}")
    logger.info(f"random seed: {seed}")

    # model path
    args.model_dir = f"{args.model_dir}/m{args_hash}"
    if not os.path.exists(args.model_dir):
        os.makedirs(args.model_dir)
    logger.info(f"checkpoint's dir is: {args.model_dir}")

    # tensorboard path
    tensorboard_path = f"{args.tensorboard_path}/t{args_hash}"
    if not os.path.exists(tensorboard_path):
        os.makedirs(tensorboard_path)
    summary_writer = dict()
    summary_writer["train"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'train'))
    summary_writer["valid"] = SummaryWriter(log_dir=os.path.join(tensorboard_path, 'log' + args_hash, 'valid'))

    return logger, summary_writer 
开发者ID:facebookresearch,项目名称:latent-treelstm,代码行数:36,代码来源:train_tree_lstm_model.py

示例7: __init__

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def __init__(self, config, resume_training=True, model_name='dense_bi_lstm'):
        # set configurations
        self.cfg, self.model_name, self.resume_training, self.start_epoch = config, model_name, resume_training, 1
        self.logger = get_logger(os.path.join(self.cfg.ckpt_path, 'log.txt'))
        # build model
        self._add_placeholder()
        self._add_embedding_lookup()
        self._build_model()
        self._add_loss_op()
        self._add_accuracy_op()
        self._add_train_op()
        print('params number: {}'.format(np.sum([np.prod(v.get_shape().as_list()) for v in tf.trainable_variables()])))
        # initialize model
        self.sess, self.saver = None, None
        self.initialize_session() 
开发者ID:IsaacChanghau,项目名称:Dense_BiLSTM,代码行数:17,代码来源:model.py

示例8: __init__

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def __init__(self):
        self.settings = get_channel_reaper_settings()
        self.logger = get_logger('channel_reaper', './audit.log') 
开发者ID:Symantec,项目名称:slack-autoarchive,代码行数:5,代码来源:slack_autoarchive.py

示例9: print_stat_message

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def print_stat_message(update, context):
    chat_id = update.effective_chat.id
    utils.get_logger().info(f'[{chat_id}] Displaying statistics', extra={'user': chat_id})

    msg = get_msg(update)
    all_jobs = [x for x in job_storage.get_jobs() if 'chat_id' in x.kwargs]
    average_interval = sum([x.trigger.interval.seconds for x in all_jobs]) / 60 / len(all_jobs)

    termin_list = [x.kwargs['termin'] for x in all_jobs]
    most_popular_termin = max(set(termin_list), key=lambda x: termin_list.count(x))

    msg.reply_text(f'ℹ️ Some piece of statistics:\n\n'
                   f'{len(all_jobs)} active subscription(s)\n'
                   f'{average_interval} min average interval\n'
                   f'{most_popular_termin} is the most popular termin') 
开发者ID:okainov,项目名称:munich-scripts,代码行数:17,代码来源:printers.py

示例10: clear_jobs

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def clear_jobs():
    logger = utils.get_logger()
    logger.info("Cleaning jobs...")

    # remove jobs scheduled more than a week ago
    for job in scheduler.get_jobs():
        if 'created_at' in job.kwargs and (datetime.datetime.now() - job.kwargs['created_at']).days >= 7:
            logger.info("Removing job %s" % job.kwargs['chat_id'], extra={'user': job.kwargs['chat_id']})
            remove_subscription(job.kwargs['chat_id'], automatic=True) 
开发者ID:okainov,项目名称:munich-scripts,代码行数:11,代码来源:job_storage.py

示例11: init_scheduler

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def init_scheduler():
    scheduler.start()
    if not scheduler.get_job('cleanup'):
        scheduler.add_job(clear_jobs, "interval", minutes=30, id="cleanup")
    else:
        # Just to make sure interval is always correct here
        utils.get_logger().info("Rescheduling cleanup job...")
        scheduler.reschedule_job('cleanup', trigger='interval', minutes=30) 
开发者ID:okainov,项目名称:munich-scripts,代码行数:10,代码来源:job_storage.py

示例12: add_subscription

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def add_subscription(update, context, interval):
    logger = utils.get_logger()
    metric_collector = MetricCollector.get_collector()

    buro = context.user_data['buro']
    termin = context.user_data['termin_type']
    chat_id = str(update.effective_chat.id)
    kwargs = {'chat_id': chat_id, 'buro': buro.get_id(), 'termin': termin, 'created_at': datetime.datetime.now()}
    scheduler.add_job(printers.notify_about_termins, 'interval', kwargs=kwargs, minutes=int(interval),
                      id=chat_id)

    logger.info(f'[{chat_id}] Subscription for %s-{termin} created with interval {interval}' % buro.get_name(), extra={'user': chat_id})
    metric_collector.log_subscription(buro=buro, appointment=termin, interval=interval, user=int(chat_id)) 
开发者ID:okainov,项目名称:munich-scripts,代码行数:15,代码来源:job_storage.py

示例13: remove_subscription

# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_logger [as 别名]
def remove_subscription(chat_id, automatic=False):
    if not scheduler.get_job(chat_id):
        return
    scheduler.remove_job(chat_id)
    if automatic:
        utils.get_logger().info(f'[{chat_id}] Subscription removed since it\'s expired', extra={'user': chat_id})
        utils.get_bot().send_message(chat_id=chat_id,
                                     text='Subscription was removed since it was created more than a week ago')
    else:
        utils.get_logger().info(f'[{chat_id}] Subscription removed by request', extra={'user': chat_id})
        utils.get_bot().send_message(chat_id=chat_id, text='You were unsubscribed successfully') 
开发者ID:okainov,项目名称:munich-scripts,代码行数:13,代码来源:job_storage.py


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