本文簡要介紹python語言中 torch.distributions.mixture_same_family.MixtureSameFamily
的用法。
用法:
class torch.distributions.mixture_same_family.MixtureSameFamily(mixture_distribution, component_distribution, validate_args=None)
mixture_distribution-
torch.distributions.Categorical
類似實例。管理選擇組件的概率。類別數必須與component_distribution
的最右側批次維度匹配。必須有標量batch_shape
或batch_shape
匹配component_distribution.batch_shape[:-1]
component_distribution-
torch.distributions.Distribution
類似實例。最右邊的批量維度索引組件。
基礎:
torch.distributions.distribution.Distribution
MixtureSameFamily
分布實現了(一批)混合分布,其中所有分量都來自相同分布類型的不同參數化。它由Categorical
“selecting distribution”(在k
組件之上)和組件分布參數化,即具有最右側批次形狀(等於[k]
)的Distribution
,它索引每個(批次)組件。例子:
# Construct Gaussian Mixture Model in 1D consisting of 5 equally # weighted normal distributions >>> mix = D.Categorical(torch.ones(5,)) >>> comp = D.Normal(torch.randn(5,), torch.rand(5,)) >>> gmm = MixtureSameFamily(mix, comp) # Construct Gaussian Mixture Modle in 2D consisting of 5 equally # weighted bivariate normal distributions >>> mix = D.Categorical(torch.ones(5,)) >>> comp = D.Independent(D.Normal( torch.randn(5,2), torch.rand(5,2)), 1) >>> gmm = MixtureSameFamily(mix, comp) # Construct a batch of 3 Gaussian Mixture Models in 2D each # consisting of 5 random weighted bivariate normal distributions >>> mix = D.Categorical(torch.rand(3,5)) >>> comp = D.Independent(D.Normal( torch.randn(3,5,2), torch.rand(3,5,2)), 1) >>> gmm = MixtureSameFamily(mix, comp)
參數:
相關用法
- Python PyTorch Mish用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch MultiStepLR用法及代碼示例
- Python PyTorch Module.buffers用法及代碼示例
- Python PyTorch Module.register_full_backward_hook用法及代碼示例
- Python PyTorch Module.named_modules用法及代碼示例
- Python PyTorch Module.parameters用法及代碼示例
- Python PyTorch MaxPool1d用法及代碼示例
- Python PyTorch Module.register_forward_hook用法及代碼示例
- Python PyTorch MetaInferGroupedPooledEmbeddingsLookup.state_dict用法及代碼示例
- Python PyTorch Module.named_parameters用法及代碼示例
- Python PyTorch MetaInferGroupedEmbeddingsLookup.named_buffers用法及代碼示例
- Python PyTorch ModuleList用法及代碼示例
- Python PyTorch MultiLabelMarginLoss用法及代碼示例
- Python PyTorch MultiplicativeLR用法及代碼示例
- Python PyTorch MultiheadAttention用法及代碼示例
- Python PyTorch MpSerialExecutor用法及代碼示例
- Python PyTorch MaxUnpool1d用法及代碼示例
- Python PyTorch Mapper用法及代碼示例
- Python PyTorch MultivariateNormal用法及代碼示例
- Python PyTorch Module.state_dict用法及代碼示例
- Python PyTorch MapKeyZipper用法及代碼示例
- Python PyTorch MultiScaleRoIAlign用法及代碼示例
- Python PyTorch MultiheadAttentionContainer.__init__用法及代碼示例
- Python PyTorch MarginRankingLoss用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.distributions.mixture_same_family.MixtureSameFamily。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。