/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__/categorical.cpython-36.pyc (5813B)
3 Egp@sTddlZddlmZddlmZddlmZddlmZm Z m Z GdddeZ dS)N)nan) constraints) Distribution)probs_to_logitslogits_to_probs lazy_propertycseZdZdZejejdZdZd!fdd Z d"fdd Z d d Z ej dd d d dZ eddZeddZeddZeddZeddZejfddZddZddZd#dd ZZS)$ Categoricala Creates a categorical distribution parameterized by either :attr:`probs` or :attr:`logits` (but not both). .. note:: It is equivalent to the distribution that :func:`torch.multinomial` samples from. Samples are integers from :math:`\{0, \ldots, K-1\}` where `K` is ``probs.size(-1)``. If `probs` is 1-dimensional with length-`K`, each element is the relative probability of sampling the class at that index. If `probs` is N-dimensional, the first N-1 dimensions are treated as a batch of relative probability vectors. .. note:: The `probs` argument must be non-negative, finite and have a non-zero sum, and it will be normalized to sum to 1 along the last dimension. :attr:`probs` will return this normalized value. The `logits` argument will be interpreted as unnormalized log probabilities and can therefore be any real number. It will likewise be normalized so that the resulting probabilities sum to 1 along the last dimension. :attr:`logits` will return this normalized value. See also: :func:`torch.multinomial` Example:: >>> m = Categorical(torch.tensor([ 0.25, 0.25, 0.25, 0.25 ])) >>> m.sample() # equal probability of 0, 1, 2, 3 tensor(3) Args: probs (Tensor): event probabilities logits (Tensor): event log probabilities (unnormalized) )probslogitsTNcs|dk|dkkrtd|dk rJ|jdkr4td||jd dd|_n(|jdkr^td||jd dd|_|dk r|jn|j|_|jjd |_|jj dkr|jjdd nt j }t t |j||ddS) Nz;Either `probs` or `logits` must be specified, but not both.z3`probs` parameter must be at least one-dimensional.T)keepdimz4`logits` parameter must be at least one-dimensional.)dimr ) validate_argsrrr) ValueErrorr sumr Z logsumexpr _paramsize _num_eventsZ ndimensiontorchSizesuperr__init__)selfr r r batch_shape) __class__K/usr/local/lib64/python3.6/site-packages/torch/distributions/categorical.pyr1s  (zCategorical.__init__cs|jt|}tj|}|tj|jf}d|jkrH|jj||_|j|_d|jkrh|j j||_ |j |_|j|_t t|j |dd|j |_ |S)Nr r F)r) Z_get_checked_instancerrrr__dict__r expandrr rr_validate_args)rrZ _instancenew param_shape)rrrrBs    zCategorical.expandcOs|jj||S)N)rr!)rargskwargsrrr_newQszCategorical._newr)Z is_discreteZ event_dimcCstjd|jdS)Nrr )rZinteger_intervalr)rrrrsupportTszCategorical.supportcCs t|jS)N)rr )rrrrr XszCategorical.logitscCs t|jS)N)rr )rrrrr \szCategorical.probscCs |jjS)N)rr)rrrrr"`szCategorical.param_shapecCstj|jt|jj|jjdS)N)dtypedevice)rfull_extended_shaperr r'r()rrrrmeandszCategorical.meancCstj|jt|jj|jjdS)N)r'r()rr)r*rr r'r()rrrrvariancehszCategorical.variancecCsJt|tjstj|}|jjd|j}tj||jdj}|j|j |S)Nr Tr) isinstancerrr ZreshaperZ multinomialZnumelTr*)rZ sample_shapeZprobs_2dZ samples_2drrrsamplels   zCategorical.samplecCsR|jr|j||jjd}tj||j\}}|dddf}|jd|jdS)Nr .rrr) r Z_validate_samplelongZ unsqueezerZbroadcast_tensorsr gatherZsqueeze)rvalueZlog_pmfrrrlog_probss  zCategorical.log_probcCs6tj|jjj}tj|j|d}||j}|jd S)N)minr r)rZfinfor r'r4clampr r)rZmin_realr Zp_log_prrrentropy{s zCategorical.entropycCsL|j}tj|tj|jjd}|jddt|j}|rH|j d|j}|S)N)r'r(r r)r)r r)r) rrZaranger0rr(viewlenZ _batch_shaper)rrZ num_eventsvaluesrrrenumerate_supports zCategorical.enumerate_support)NNN)N)T)__name__ __module__ __qualname____doc__rZsimplexZ real_vectorZarg_constraintsZhas_enumerate_supportrrr%Zdependent_propertyr&rr r propertyr"r+r,rrr/r3r6r: __classcell__rr)rrrs"$      r) rZ torch._sixrZtorch.distributionsrZ torch.distributions.distributionrZtorch.distributions.utilsrrrrrrrrs