79144335

Date: 2024-10-31 10:29:20
Score: 1.5
Natty:
Report link

I know lambda functions are prohibited by PEP8, but when I locally need it, I sometimes use

torch_geom = lambda t, *a, **kw: t.log().mean(*a, **kw).exp()  # Geometric mean
torch_harm = lambda t, *a, **kw: 1 / (1 / t).mean(*a, **kw)  # Harmonic mean
...

I find that it is a neat little way of getting what I want with a syntax matching that of pre-existing functions like torch.mean etc...

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ego-thales