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


Python logger.info方法代码示例

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


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

示例1: end_epoch

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def end_epoch(self):
        """
        Finally arrived at the end of epoch (full pass on dataset).
        Do some tensorboard logging and checkpoint saving.
        """
        logger.info(f"{self.n_sequences_epoch} sequences have been trained during this epoch.")

        if self.is_master:
            self.save_checkpoint(checkpoint_name=f"model_epoch_{self.epoch}.pth")
            self.tensorboard.add_scalar(
                tag="epoch/loss", scalar_value=self.total_loss_epoch / self.n_iter, global_step=self.epoch
            )

        self.epoch += 1
        self.n_sequences_epoch = 0
        self.n_iter = 0
        self.total_loss_epoch = 0 
开发者ID:monologg,项目名称:DistilKoBERT,代码行数:19,代码来源:distiller.py

示例2: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, args):
		super(CEMLearner, self).__init__(args)

		policy_conf = {'name': 'local_learning_{}'.format(self.actor_id),
					   'input_shape': self.input_shape,
					   'num_act': self.num_actions,
					   'args': args}

		self.local_network = args.network(policy_conf)
		self.num_params = np.sum([
			np.prod(v.get_shape().as_list())
			for v in self.local_network.params])

		logger.info('Parameter count: {}'.format(self.num_params))
		self.mu = np.zeros(self.num_params)
		self.sigma = np.ones(self.num_params)
		self.num_samples = args.episodes_per_batch
		self.num_epochs = args.num_epochs

		if self.is_master():
			var_list = self.local_network.params
			self.saver = tf.train.Saver(var_list=var_list, max_to_keep=3,
                                        keep_checkpoint_every_n_hours=2) 
开发者ID:steveKapturowski,项目名称:tensorflow-rl,代码行数:25,代码来源:cem_actor_learner.py

示例3: _add_archives

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def _add_archives(self, collection):
        logger.info("%s " % "article", False)
        result = ""
        archives = list(collection.find({}))
        page_count = len(archives) / 10 + 1
        result += self._add_one(
                "archives",
                datetime.now()
            )
        for index in xrange(page_count):
            result += self._add_one(
                "%s/%d" % ("archives", index),
                datetime.now()
            )
        for article in archives:
            result += self._add_one(
                "%s/%s" % ("article", article["slug"]),
                datetime.strptime(article["date"], "%Y.%m.%d %H:%M")
            )
        return result 
开发者ID:dtysky,项目名称:BlogReworkPro,代码行数:22,代码来源:sitemap_generator.py

示例4: generate

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def generate(self):
        logger.info("Sitemap: Writing start...")
        with open(config["sitemap_path"], "w") as f:
            f.write(template["begin"])
            f.write(self._add_static())
            logger.info("Sitemap: Writing: ")
            for url in ["tag", "author", "category"]:
                f.write(
                    self._add_collection(url, self._collections[url])
                )
            f.write(
                self._add_archives(self._collections["article"])
            )
            f.write(template["end"])
            f.close()
        logger.info("Sitemap: Writing done...") 
开发者ID:dtysky,项目名称:BlogReworkPro,代码行数:18,代码来源:sitemap_generator.py

示例5: _update_files

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def _update_files(self, file_names, time):
        if not os.path.exists(config["feeds_dir_path"]):
            os.mkdir(config["feeds_dir_path"])
        for name_pair in file_names:
            name, view = name_pair["slug"].encode("utf-8"), name_pair["view"].encode("utf-8")
            if name not in self._files:
                file_name = "%s/%s.rss.xml" % (
                    config["feeds_dir_path"],
                    name
                    )
                self._files[name] = open(file_name, "w")
                self._files[name].write(
                    template["begin"].format(
                        config["site_title"],
                        config["site_url"],
                        config["site_description"],
                        "%s/%s" % (
                            config["site_url"],
                            file_name
                        ),
                        time
                    )
                )
                logger.info("'%s' " % view, False) 
开发者ID:dtysky,项目名称:BlogReworkPro,代码行数:26,代码来源:feeds_generator.py

示例6: write

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def write(self, file_path, mode="delete", page=None):
        logger.info("Writing start: %s" % file_path)

        self._file_path = file_path
        if mode != "delete" and page == None:
            self._error("Mode is not 'delete', argument 'page' is required !")
        if mode == "update":
            if self._articles.find_one(
                {
                    "file": file_path
                }
            ):
                self._update(file_path, page)
            else:
                self._insert(page)
        elif mode == "delete":
            self._delete(file_path)
        else:
            self._error("Unexpected mode '%s' !" % mode) 
开发者ID:dtysky,项目名称:BlogReworkPro,代码行数:21,代码来源:writer.py

示例7: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, name, is_train, norm='instance', activation='leaky',
                 image_size=128, latent_dim=8, use_resnet=True):
        logger.info('Init Encoder %s', name)
        self.name = name
        self._is_train = is_train
        self._norm = norm
        self._activation = activation
        self._reuse = False
        self._image_size = image_size
        self._latent_dim = latent_dim
        self._use_resnet = use_resnet 
开发者ID:clvrai,项目名称:BicycleGAN-Tensorflow,代码行数:13,代码来源:encoder.py

示例8: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, name, is_train, norm='instance', activation='leaky', image_size=128):
        logger.info('Init Discriminator %s', name)
        self.name = name
        self._is_train = is_train
        self._norm = norm
        self._activation = activation
        self._reuse = False
        self._image_size = image_size 
开发者ID:clvrai,项目名称:BicycleGAN-Tensorflow,代码行数:10,代码来源:discriminator.py

示例9: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, name, is_train, norm='batch', image_size=128):
        logger.info('Init Generator %s', name)
        self.name = name
        self._is_train = is_train
        self._norm = norm
        self._reuse = False
        self._image_size = image_size 
开发者ID:clvrai,项目名称:BicycleGAN-Tensorflow,代码行数:9,代码来源:generator.py

示例10: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, name, is_train, norm='instance', activation='leaky'):
        logger.info('Init Discriminator %s', name)
        self.name = name
        self._is_train = is_train
        self._norm = norm
        self._activation = activation
        self._reuse = False 
开发者ID:clvrai,项目名称:CycleGAN-Tensorflow,代码行数:9,代码来源:discriminator.py

示例11: __init__

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def __init__(self, name, is_train, norm='instance', activation='relu',
                 image_size=128):
        logger.info('Init Generator %s', name)
        self.name = name
        self._is_train = is_train
        self._norm = norm
        self._activation = activation
        self._num_res_block = 6 if image_size == 128 else 9
        self._reuse = False 
开发者ID:clvrai,项目名称:CycleGAN-Tensorflow,代码行数:11,代码来源:generator.py

示例12: remove_long_sequences

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def remove_long_sequences(self):
        """
        Sequences that are too long are splitted by chunk of max_model_input_size.
        """
        max_len = self.params.max_model_input_size
        indices = self.lengths > max_len
        logger.info(f"Splitting {sum(indices)} too long sequences.")

        def divide_chunks(l, n):
            return [l[i : i + n] for i in range(0, len(l), n)]

        new_tok_ids = []
        new_lengths = []
        if self.params.mlm:
            cls_id, sep_id = self.params.special_tok_ids["cls_token"], self.params.special_tok_ids["sep_token"]
        else:
            cls_id, sep_id = self.params.special_tok_ids["bos_token"], self.params.special_tok_ids["eos_token"]

        for seq_, len_ in zip(self.token_ids, self.lengths):
            assert (seq_[0] == cls_id) and (seq_[-1] == sep_id), seq_
            if len_ <= max_len:
                new_tok_ids.append(seq_)
                new_lengths.append(len_)
            else:
                sub_seqs = []
                for sub_s in divide_chunks(seq_, max_len - 2):
                    if sub_s[0] != cls_id:
                        sub_s = np.insert(sub_s, 0, cls_id)
                    if sub_s[-1] != sep_id:
                        sub_s = np.insert(sub_s, len(sub_s), sep_id)
                    assert len(sub_s) <= max_len
                    assert (sub_s[0] == cls_id) and (sub_s[-1] == sep_id), sub_s
                    sub_seqs.append(sub_s)

                new_tok_ids.extend(sub_seqs)
                new_lengths.extend([len(l) for l in sub_seqs])

        self.token_ids = np.array(new_tok_ids)
        self.lengths = np.array(new_lengths) 
开发者ID:bhoov,项目名称:exbert,代码行数:41,代码来源:lm_seqs_dataset.py

示例13: remove_empty_sequences

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def remove_empty_sequences(self):
        """
        Too short sequences are simply removed. This could be tunedd.
        """
        init_size = len(self)
        indices = self.lengths > 11
        self.token_ids = self.token_ids[indices]
        self.lengths = self.lengths[indices]
        new_size = len(self)
        logger.info(f"Remove {init_size - new_size} too short (<=11 tokens) sequences.") 
开发者ID:bhoov,项目名称:exbert,代码行数:12,代码来源:lm_seqs_dataset.py

示例14: remove_unknown_sequences

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def remove_unknown_sequences(self):
        """
        Remove sequences with a (too) high level of unknown tokens.
        """
        if "unk_token" not in self.params.special_tok_ids:
            return
        else:
            unk_token_id = self.params.special_tok_ids["unk_token"]
        init_size = len(self)
        unk_occs = np.array([np.count_nonzero(a == unk_token_id) for a in self.token_ids])
        indices = (unk_occs / self.lengths) < 0.5
        self.token_ids = self.token_ids[indices]
        self.lengths = self.lengths[indices]
        new_size = len(self)
        logger.info(f"Remove {init_size - new_size} sequences with a high level of unknown tokens (50%).") 
开发者ID:bhoov,项目名称:exbert,代码行数:17,代码来源:lm_seqs_dataset.py

示例15: print_statistics

# 需要导入模块: from utils import logger [as 别名]
# 或者: from utils.logger import info [as 别名]
def print_statistics(self):
        """
        Print some statistics on the corpus. Only the master process.
        """
        if not self.params.is_master:
            return
        logger.info(f"{len(self)} sequences")
        # data_len = sum(self.lengths)
        # nb_unique_tokens = len(Counter(list(chain(*self.token_ids))))
        # logger.info(f'{data_len} tokens ({nb_unique_tokens} unique)')

        # unk_idx = self.params.special_tok_ids['unk_token']
        # nb_unkown = sum([(t==unk_idx).sum() for t in self.token_ids])
        # logger.info(f'{nb_unkown} unknown tokens (covering {100*nb_unkown/data_len:.2f}% of the data)') 
开发者ID:bhoov,项目名称:exbert,代码行数:16,代码来源:lm_seqs_dataset.py


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