/usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__/beta.cpython-36.pyc (3682B)
3
EgN
@ s\ d dl mZmZ d dlZd dlmZ d dlmZ d dlm Z d dl
mZ G dd de ZdS ) )RealNumberN)constraints) Dirichlet)ExponentialFamily)
broadcast_allc s e Zd ZdZejejdZejZdZ d fdd Z
d fdd Zed d
Z
edd Zf fd
dZdd Zdd Zedd Zedd Zedd Zdd Z ZS )Betaa8
Beta distribution parameterized by :attr:`concentration1` and :attr:`concentration0`.
Example::
>>> m = Beta(torch.tensor([0.5]), torch.tensor([0.5]))
>>> m.sample() # Beta distributed with concentration concentration1 and concentration0
tensor([ 0.1046])
Args:
concentration1 (float or Tensor): 1st concentration parameter of the distribution
(often referred to as alpha)
concentration0 (float or Tensor): 2nd concentration parameter of the distribution
(often referred to as beta)
)concentration1concentration0TNc st t |tr,t |tr,tjt|t|g}nt||\}}tj||gd}t||d| _t t
| j| jj|d d S )N )
validate_args)
isinstancer torchtensorfloatr stackr
_dirichletsuperr __init__Z_batch_shape)selfr r
r Zconcentration1_concentration0) __class__ D/usr/local/lib64/python3.6/site-packages/torch/distributions/beta.pyr s z
Beta.__init__c sD | j t|}tj|}| jj||_tt|j|dd | j|_|S )NF)r ) Z_get_checked_instancer r Sizer expandr r _validate_args)r Zbatch_shapeZ _instancenew)r r r r ' s
zBeta.expandc C s | j | j | j S )N)r r
)r r r r mean/ s z Beta.meanc C s* | j | j }| j | j |jd|d S )N r )r r
pow)r totalr r r variance3 s
z
Beta.variancec C s | j j|jddS )Nr r r
)r rsampleselect)r Zsample_shaper r r r# 9 s zBeta.rsamplec C s0 | j r| j| tj|d| gd}| jj|S )Ng ?r r
)r Z_validate_sampler r r log_prob)r valueZheads_tailsr r r r% <