Torch Utils¶
-
pysgmcmc.torch_utils.
get_name
(object_: Any) → str[source]¶ - Get a string representation of the name of object_.
- Defaults to object_.__name__ for most objects. For classes in module pysgmcmc.optimizers and pysgmcmc.models.losses this returns an abbreviated name identifying the loss or optimizer.
Parameters: object (typing.Any) – Any python object. Must have a __name__ attribute. Returns: name – String represenation of the name of object_. Return type: str Examples
For most objects, this function simply returns their __name__ attribute:
>>> from torch.optim import Adam >>> get_name(Adam) == Adam.__name__ True
If an object sets a name attribute, that is used instead:
>>> from pysgmcmc.models.losses import NegativeLogLikelihood >>> get_name(NegativeLogLikelihood) == "NLL" != NegativeLogLikelihood.__name__ True