本文整理匯總了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
示例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)
示例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
示例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...")
示例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)
示例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)
示例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
示例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
示例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
示例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
示例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
示例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)
示例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.")
示例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%).")
示例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)')