/usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__/exponential.cpython-36.pyc (3363B)
3
Eg @ sL d dl mZ d dlZd dlmZ d dlmZ d dlmZ G dd deZ dS ) )NumberN)constraints)ExponentialFamily)
broadcast_allc s e Zd ZdZdejiZejZdZdZ e
dd Ze
dd Ze
d d
Z
d fdd
Zd fdd Zej fddZdd Zdd Zdd Zdd Ze
dd Zdd Z ZS ) Exponentiala4
Creates a Exponential distribution parameterized by :attr:`rate`.
Example::
>>> m = Exponential(torch.tensor([1.0]))
>>> m.sample() # Exponential distributed with rate=1
tensor([ 0.1046])
Args:
rate (float or Tensor): rate = 1 / scale of the distribution
rateTr c C s
| j j S )N)r
reciprocal)self r
K/usr/local/lib64/python3.6/site-packages/torch/distributions/exponential.pymean s zExponential.meanc C s
| j j S )N)r r )r r
r
r stddev s zExponential.stddevc C s | j jdS )N )r pow)r r
r
r variance# s zExponential.varianceNc s@ t |\| _t|trtj n| jj }tt| j ||d d S )N)
validate_args)
r r
isinstancer torchSizesizesuperr __init__)r r r batch_shape) __class__r
r r ' s zExponential.__init__c sD | j t|}tj|}| jj||_tt|j|dd | j|_|S )NF)r ) Z_get_checked_instancer r r r expandr r _validate_args)r r Z _instancenew)r r
r r , s
zExponential.expandc C sT | j |}tjj r>tj|| jj| jjd}| j | j S | jj |j
| j S )N)dtypedevice)Z_extended_shaper _CZ_get_tracing_stateZrandr r r log1pr Zexponential_)r Zsample_shapeshapeur
r
r rsample4 s
zExponential.rsamplec C s$ | j r| j| | jj | j| S )N)r _validate_sampler log)r valuer
r
r log_prob<