make style (#11442)

This commit is contained in:
Patrick von Platen
2021-04-26 13:50:34 +02:00
committed by GitHub
parent 04ab2ca639
commit 32dbb2d954
105 changed files with 202 additions and 202 deletions

View File

@@ -49,14 +49,14 @@ logger = logging.getLogger(__name__)
def entropy(p):
""" Compute the entropy of a probability distribution """
"""Compute the entropy of a probability distribution"""
plogp = p * torch.log(p)
plogp[p == 0] = 0
return -plogp.sum(dim=-1)
def print_2d_tensor(tensor):
""" Print a 2D tensor """
"""Print a 2D tensor"""
logger.info("lv, h >\t" + "\t".join(f"{x + 1}" for x in range(len(tensor))))
for row in range(len(tensor)):
if tensor.dtype != torch.long:

View File

@@ -36,7 +36,7 @@ def save_model(model, dirpath):
def entropy(p, unlogit=False):
""" Compute the entropy of a probability distribution """
"""Compute the entropy of a probability distribution"""
exponent = 2
if unlogit:
p = torch.pow(p, exponent)
@@ -46,7 +46,7 @@ def entropy(p, unlogit=False):
def print_2d_tensor(tensor):
""" Print a 2D tensor """
"""Print a 2D tensor"""
logger.info("lv, h >\t" + "\t".join(f"{x + 1}" for x in range(len(tensor))))
for row in range(len(tensor)):
if tensor.dtype != torch.long: