/usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__
NameSizeModeActions
bernoulli.cpython-36.pyc44450644editdlrm
beta.cpython-36.pyc36820644editdlrm
binomial.cpython-36.pyc47610644editdlrm
categorical.cpython-36.pyc58130644editdlrm
cauchy.cpython-36.pyc33100644editdlrm
chi2.cpython-36.pyc14190644editdlrm
constraints.cpython-36.pyc222170644editdlrm
constraint_registry.cpython-36.pyc98950644editdlrm
continuous_bernoulli.cpython-36.pyc80770644editdlrm
dirichlet.cpython-36.pyc40850644editdlrm
distribution.cpython-36.pyc118220644editdlrm
exponential.cpython-36.pyc33630644editdlrm
exp_family.cpython-36.pyc28760644editdlrm
fishersnedecor.cpython-36.pyc32120644editdlrm
gamma.cpython-36.pyc34550644editdlrm
geometric.cpython-36.pyc41830644editdlrm
gumbel.cpython-36.pyc28640644editdlrm
half_cauchy.cpython-36.pyc29300644editdlrm
half_normal.cpython-36.pyc28210644editdlrm
independent.cpython-36.pyc45060644editdlrm
kl.cpython-36.pyc258440644editdlrm
kumaraswamy.cpython-36.pyc30400644editdlrm
laplace.cpython-36.pyc34420644editdlrm
lkj_cholesky.cpython-36.pyc45750644editdlrm
logistic_normal.cpython-36.pyc23200644editdlrm
log_normal.cpython-36.pyc24380644editdlrm
lowrank_multivariate_normal.cpython-36.pyc80740644editdlrm
mixture_same_family.cpython-36.pyc70730644editdlrm
multinomial.cpython-36.pyc50200644editdlrm
multivariate_normal.cpython-36.pyc85340644editdlrm
negative_binomial.cpython-36.pyc41490644editdlrm
normal.cpython-36.pyc41380644editdlrm
one_hot_categorical.cpython-36.pyc51730644editdlrm
pareto.cpython-36.pyc25160644editdlrm
poisson.cpython-36.pyc26820644editdlrm
relaxed_bernoulli.cpython-36.pyc55950644editdlrm
relaxed_categorical.cpython-36.pyc55630644editdlrm
studentT.cpython-36.pyc34830644editdlrm
transformed_distribution.cpython-36.pyc73350644editdlrm
transforms.cpython-36.pyc429810644editdlrm
uniform.cpython-36.pyc35800644editdlrm
utils.cpython-36.pyc68020644editdlrm
von_mises.cpython-36.pyc50790644editdlrm
weibull.cpython-36.pyc27370644editdlrm
__init__.cpython-36.pyc59810644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__/constraints.cpython-36.pyc (22217B)
3 EgC@sXdZddlZddddddd d d d d dddddddddddddddgZGdddeZGdddeZd dZGd!d"d"eeZGd#d$d$eZ Gd%d&d&eZ Gd'd(d(eZ Gd)d*d*eZ Gd+d,d,eZ Gd-d.d.eZGd/d0d0eZGd1d2d2eZGd3d4d4eZGd5d6d6eZGd7d8d8eZGd9d:d:eZGd;d<dd>eZGd?d@d@eZGdAdBdBeZGdCdDdDeZGdEdFdFeZGdGdHdHeZGdIdJdJeZeZeZe Ze Z e Z!edZ"edKZ#e Z$eZ%ee%dKZ&edLZ'edLZ(eZ)eZ*eZ+eZ,edLdMZ-eZ.eZ/eZ0eZ1eZ2eZ3eZ4eZ5eZ6dS)Na_ The following constraints are implemented: - ``constraints.boolean`` - ``constraints.cat`` - ``constraints.corr_cholesky`` - ``constraints.dependent`` - ``constraints.greater_than(lower_bound)`` - ``constraints.greater_than_eq(lower_bound)`` - ``constraints.independent(constraint, reinterpreted_batch_ndims)`` - ``constraints.integer_interval(lower_bound, upper_bound)`` - ``constraints.interval(lower_bound, upper_bound)`` - ``constraints.less_than(upper_bound)`` - ``constraints.lower_cholesky`` - ``constraints.lower_triangular`` - ``constraints.multinomial`` - ``constraints.nonnegative_integer`` - ``constraints.one_hot`` - ``constraints.positive_definite`` - ``constraints.positive_integer`` - ``constraints.positive`` - ``constraints.real_vector`` - ``constraints.real`` - ``constraints.simplex`` - ``constraints.stack`` - ``constraints.unit_interval`` N Constraintbooleancat corr_cholesky dependentdependent_property greater_thangreater_than_eq independentinteger_intervalintervalhalf_open_interval is_dependent less_thanlower_choleskylower_triangular multinomialnonnegative_integerpositivepositive_definitepositive_integerreal real_vectorsimplexstack unit_intervalc@s(eZdZdZdZdZddZddZdS) ra Abstract base class for constraints. A constraint object represents a region over which a variable is valid, e.g. within which a variable can be optimized. Attributes: is_discrete (bool): Whether constrained space is discrete. Defaults to False. event_dim (int): Number of rightmost dimensions that together define an event. The :meth:`check` method will remove this many dimensions when computing validity. FrcCstdS)z Returns a byte tensor of ``sample_shape + batch_shape`` indicating whether each event in value satisfies this constraint. N)NotImplementedError)selfvaluerK/usr/local/lib64/python3.6/site-packages/torch/distributions/constraints.pycheckNszConstraint.checkcCs|jjdddS)Nz()) __class____name__)rrrr __repr__UszConstraint.__repr__N)r$ __module__ __qualname____doc__ is_discrete event_dimr!r%rrrr r=s  csXeZdZdZeedfdd ZeddZeddZeedd d Z d d Z Z S) _DependentaI Placeholder for variables whose support depends on other variables. These variables obey no simple coordinate-wise constraints. Args: is_discrete (bool): Optional value of ``.is_discrete`` in case this can be computed statically. If not provided, access to the ``.is_discrete`` attribute will raise a NotImplementedError. event_dim (int): Optional value of ``.event_dim`` in case this can be computed statically. If not provided, access to the ``.event_dim`` attribute will raise a NotImplementedError. )r)r*cs||_||_tjdS)N) _is_discrete _event_dimsuper__init__)rr)r*)r#rr r/fsz_Dependent.__init__cCs|jtkrtd|jS)Nz,.is_discrete cannot be determined statically)r,NotImplementedr)rrrr r)ks z_Dependent.is_discretecCs|jtkrtd|jS)Nz*.event_dim cannot be determined statically)r-r0r)rrrr r*qs z_Dependent.event_dimcCs(|tkr|j}|tkr|j}t||dS)z Support for syntax to customize static attributes:: constraints.dependent(is_discrete=True, event_dim=1) )r)r*)r0r,r-r+)rr)r*rrr __call__ws z_Dependent.__call__cCs tddS)Nz1Cannot determine validity of dependent constraint) ValueError)rxrrr r!sz_Dependent.check) r$r&r'r(r0r/propertyr)r*r1r! __classcell__rr)r#r r+Ys     r+cCs t|tS)N) isinstancer+) constraintrrr rscs2eZdZdZdeedfdd ZddZZS) _DependentPropertya Decorator that extends @property to act like a `Dependent` constraint when called on a class and act like a property when called on an object. Example:: class Uniform(Distribution): def __init__(self, low, high): self.low = low self.high = high @constraints.dependent_property(is_discrete=False, event_dim=0) def support(self): return constraints.interval(self.low, self.high) Args: fn (callable): The function to be decorated. is_discrete (bool): Optional value of ``.is_discrete`` in case this can be computed statically. If not provided, access to the ``.is_discrete`` attribute will raise a NotImplementedError. event_dim (int): Optional value of ``.event_dim`` in case this can be computed statically. If not provided, access to the ``.event_dim`` attribute will raise a NotImplementedError. N)r)r*cstj|||_||_dS)N)r.r/r,r-)rfnr)r*)r#rr r/s z_DependentProperty.__init__cCst||j|jdS)z Support for syntax to customize static attributes:: @constraints.dependent_property(is_discrete=True, event_dim=1) def support(self): ... )r)r*)r8r,r-)rr9rrr r1sz_DependentProperty.__call__)N)r$r&r'r(r0r/r1r5rr)r#r r8sr8csHeZdZdZfddZeddZeddZdd Zd d Z Z S) _IndependentConstraintz Wraps a constraint by aggregating over ``reinterpreted_batch_ndims``-many dims in :meth:`check`, so that an event is valid only if all its independent entries are valid. csBt|tstt|tst|dks(t||_||_tjdS)Nr)r6rAssertionErrorintbase_constraintreinterpreted_batch_ndimsr.r/)rr=r>)r#rr r/s  z_IndependentConstraint.__init__cCs|jjS)N)r=r))rrrr r)sz"_IndependentConstraint.is_discretecCs|jj|jS)N)r=r*r>)rrrr r*sz _IndependentConstraint.event_dimcCsp|jj|}|j|jkr@|jj|j}td|d|j|j|jd|j|jd}|jd}|S)NzExpected value.dim() >= z but got r")r?r?) r=r!dimr>r*r2Zreshapeshapeall)rrresultexpectedrrr r!s " z_IndependentConstraint.checkcCs"dj|jjddt|j|jS)Nz {}({}, {})r")formatr#r$reprr=r>)rrrr r%sz_IndependentConstraint.__repr__) r$r&r'r(r/r4r)r*r!r%r5rr)r#r r:s     r:c@seZdZdZdZddZdS)_Booleanz/ Constrain to the two values `{0, 1}`. TcCs|dk|dkBS)Nrr"r)rrrrr r!sz_Boolean.checkN)r$r&r'r(r)r!rrrr rGsrGc@s eZdZdZdZdZddZdS)_OneHotz' Constrain to one-hot vectors. Tr"cCs.|dk|dkB}|jdjd}|jd|@S)Nrr"r?r?)sumeqrB)rrZ is_booleanZ is_normalizedrrr r!sz _OneHot.checkN)r$r&r'r(r)r*r!rrrr rHsrHcs4eZdZdZdZfddZddZddZZS) _IntegerIntervalzH Constrain to an integer interval `[lower_bound, upper_bound]`. Tcs||_||_tjdS)N) lower_bound upper_boundr.r/)rrLrM)r#rr r/sz_IntegerInterval.__init__cCs |ddk|j|k@||jk@S)Nr"r)rLrM)rrrrr r!sz_IntegerInterval.checkcCs(|jjdd}|dj|j|j7}|S)Nr"z (lower_bound={}, upper_bound={}))r#r$rErLrM)r fmt_stringrrr r%sz_IntegerInterval.__repr__) r$r&r'r(r)r/r!r%r5rr)r#r rKs  rKcs4eZdZdZdZfddZddZddZZS) _IntegerLessThanzA Constrain to an integer interval `(-inf, upper_bound]`. Tcs||_tjdS)N)rMr.r/)rrM)r#rr r/sz_IntegerLessThan.__init__cCs|ddk||jk@S)Nr"r)rM)rrrrr r! sz_IntegerLessThan.checkcCs$|jjdd}|dj|j7}|S)Nr"z(upper_bound={}))r#r$rErM)rrNrrr r%sz_IntegerLessThan.__repr__) r$r&r'r(r)r/r!r%r5rr)r#r rOs  rOcs4eZdZdZdZfddZddZddZZS) _IntegerGreaterThanz@ Constrain to an integer interval `[lower_bound, inf)`. Tcs||_tjdS)N)rLr.r/)rrL)r#rr r/sz_IntegerGreaterThan.__init__cCs|ddk||jk@S)Nr"r)rL)rrrrr r!sz_IntegerGreaterThan.checkcCs$|jjdd}|dj|j7}|S)Nr"z(lower_bound={}))r#r$rErL)rrNrrr r%"sz_IntegerGreaterThan.__repr__) r$r&r'r(r)r/r!r%r5rr)r#r rPs  rPc@seZdZdZddZdS)_RealzF Trivially constrain to the extended real line `[-inf, inf]`. cCs||kS)Nr)rrrrr r!,sz _Real.checkN)r$r&r'r(r!rrrr rQ(srQcs0eZdZdZfddZddZddZZS) _GreaterThanz= Constrain to a real half line `(lower_bound, inf]`. cs||_tjdS)N)rLr.r/)rrL)r#rr r/4sz_GreaterThan.__init__cCs |j|kS)N)rL)rrrrr r!8sz_GreaterThan.checkcCs$|jjdd}|dj|j7}|S)Nr"z(lower_bound={}))r#r$rErL)rrNrrr r%;sz_GreaterThan.__repr__)r$r&r'r(r/r!r%r5rr)r#r rR0s rRcs0eZdZdZfddZddZddZZS)_GreaterThanEqz= Constrain to a real half line `[lower_bound, inf)`. cs||_tjdS)N)rLr.r/)rrL)r#rr r/Esz_GreaterThanEq.__init__cCs |j|kS)N)rL)rrrrr r!Isz_GreaterThanEq.checkcCs$|jjdd}|dj|j7}|S)Nr"z(lower_bound={}))r#r$rErL)rrNrrr r%Lsz_GreaterThanEq.__repr__)r$r&r'r(r/r!r%r5rr)r#r rSAs rScs0eZdZdZfddZddZddZZS) _LessThanz> Constrain to a real half line `[-inf, upper_bound)`. cs||_tjdS)N)rMr.r/)rrM)r#rr r/Vsz_LessThan.__init__cCs ||jkS)N)rM)rrrrr r!Zsz_LessThan.checkcCs$|jjdd}|dj|j7}|S)Nr"z(upper_bound={}))r#r$rErM)rrNrrr r%]sz_LessThan.__repr__)r$r&r'r(r/r!r%r5rr)r#r rTRs rTcs0eZdZdZfddZddZddZZS) _IntervalzD Constrain to a real interval `[lower_bound, upper_bound]`. cs||_||_tjdS)N)rLrMr.r/)rrLrM)r#rr r/gsz_Interval.__init__cCs|j|k||jk@S)N)rLrM)rrrrr r!lsz_Interval.checkcCs(|jjdd}|dj|j|j7}|S)Nr"z (lower_bound={}, upper_bound={}))r#r$rErLrM)rrNrrr r%osz_Interval.__repr__)r$r&r'r(r/r!r%r5rr)r#r rUcs rUcs0eZdZdZfddZddZddZZS)_HalfOpenIntervalzD Constrain to a real interval `[lower_bound, upper_bound)`. cs||_||_tjdS)N)rLrMr.r/)rrLrM)r#rr r/ysz_HalfOpenInterval.__init__cCs|j|k||jk@S)N)rLrM)rrrrr r!~sz_HalfOpenInterval.checkcCs(|jjdd}|dj|j|j7}|S)Nr"z (lower_bound={}, upper_bound={}))r#r$rErLrM)rrNrrr r%sz_HalfOpenInterval.__repr__)r$r&r'r(r/r!r%r5rr)r#r rVus rVc@seZdZdZdZddZdS)_Simplexz Constrain to the unit simplex in the innermost (rightmost) dimension. Specifically: `x >= 0` and `x.sum(-1) == 1`. r"cCs(tj|dkdd|jddjdk@S)Nrr")r@gư>r?r?)torchrBrIabs)rrrrr r!sz_Simplex.checkN)r$r&r'r(r*r!rrrr rWsrWc@s(eZdZdZdZdZddZddZdS) _Multinomiala3 Constrain to nonnegative integer values summing to at most an upper bound. Note due to limitations of the Multinomial distribution, this currently checks the weaker condition ``value.sum(-1) <= upper_bound``. In the future this may be strengthened to ``value.sum(-1) == upper_bound``. Tr"cCs ||_dS)N)rM)rrMrrr r/sz_Multinomial.__init__cCs"|dkjdd|jdd|jk@S)Nrr")r@r?r?)rBrIrM)rr3rrr r!sz_Multinomial.checkN)r$r&r'r(r)r*r/r!rrrr rZs rZc@seZdZdZdZddZdS)_LowerTriangularz8 Constrain to lower-triangular square matrices. cCs.|j}||kj|jdddjddS)Nr\r"rr?)r?r?)trilviewrAmin)rr value_trilrrr r!sz_LowerTriangular.checkN)r$r&r'r(r*r!rrrr r[sr[c@seZdZdZdZddZdS)_LowerCholeskyzP Constrain to lower-triangular square matrices with positive diagonals. r\cCsR|j}||kj|jdddjdd}|jd d ddkjd d}||@S) Nr\r"r)Zdim1Zdim2r]r?)r?r?r]r?r?)r^r_rAr`Zdiagonal)rrrarZpositive_diagonalrrr r!s&z_LowerCholesky.checkN)r$r&r'r(r*r!rrrr rbsrbc@seZdZdZdZddZdS) _CorrCholeskyz} Constrain to lower-triangular square matrices with positive diagonals and each row vector being of unit length. r\cCsZtj|jj|jdd}tjj|jdd}|djj |j dd}t j ||@S)Nr" )r@g?r?r?r?) rXZfinfoZdtypeZepssizelinalgZnormdetachrYlerBrbr!)rrZtolZrow_normZ unit_row_normrrr r!sz_CorrCholesky.checkN)r$r&r'r(r*r!rrrr rcsrcc@seZdZdZdZddZdS)_PositiveDefinitez2 Constrain to positive-definite matrices. r\cCstjj|jjdjdS)Nr)rXrfZ cholesky_exinforJZ unsqueeze)rrrrr r!sz_PositiveDefinite.checkN)r$r&r'r(r*r!rrrr risricsBeZdZdZd fdd ZeddZedd Zd d ZZ S) _Catz Constraint functor that applies a sequence of constraints `cseq` at the submatrices at dimension `dim`, each of size `lengths[dim]`, in a way compatible with :func:`torch.cat`. rNcsntdd|Dstt||_|dkr8dgt|j}t||_t|jt|jksZt||_tjdS)Ncss|]}t|tVqdS)N)r6r).0crrr sz _Cat.__init__..r") rBr;listcseqlenlengthsr@r.r/)rrpr@rr)r#rr r/s  z _Cat.__init__cCstdd|jDS)Ncss|] }|jVqdS)N)r))rlrmrrr rnsz#_Cat.is_discrete..)anyrp)rrrr r)sz_Cat.is_discretecCstdd|jDS)Ncss|] }|jVqdS)N)r*)rlrmrrr rnsz!_Cat.event_dim..)maxrp)rrrr r*sz_Cat.event_dimcCs|j |jko|jkns(tg}d}xBt|j|jD]0\}}|j|j||}|j|j|||}q@Wtj ||jS)Nr) r@r;ziprprrZnarrowappendr!rXr)rrZchecksstartconstrlengthvrrr r!s( z _Cat.check)rN) r$r&r'r(r/r4r)r*r!r5rr)r#r rks   rkcsBeZdZdZd fdd ZeddZeddZd d ZZ S) _Stackz Constraint functor that applies a sequence of constraints `cseq` at the submatrices at dimension `dim`, in a way compatible with :func:`torch.stack`. rcs4tdd|Dstt||_||_tjdS)Ncss|]}t|tVqdS)N)r6r)rlrmrrr rnsz"_Stack.__init__..)rBr;rorpr@r.r/)rrpr@)r#rr r/s z_Stack.__init__cCstdd|jDS)Ncss|] }|jVqdS)N)r))rlrmrrr rnsz%_Stack.is_discrete..)rsrp)rrrr r)sz_Stack.is_discretecCs.tdd|jD}|j|dkr*|d7}|S)Ncss|] }|jVqdS)N)r*)rlrmrrr rn sz#_Stack.event_dim..rr")rtrpr@)rr@rrr r* sz_Stack.event_dimcshj jkojkns(tfddtjjD}tjddt|jDjS)Ncsg|]}jj|qSr)selectr@)rli)rrrr sz _Stack.check..cSsg|]\}}|j|qSr)r!)rlrzrxrrr r~s)r@r;rangererXrrurp)rrvsr)rrr r!s(  z _Stack.check)r) r$r&r'r(r/r4r)r*r!r5rr)r#r r{s   r{r"gg?)7r(rX__all__objectrr+rr4r8r:rGrHrKrOrPrQrRrSrTrUrVrWrZr[rbrcrirkr{rrr rZone_hotrrr rrrZ nonnegativerr rrrr r rrrrrrrrrrr s.($     #