本文簡要介紹python語言中 torch.dsplit
的用法。
用法:
torch.dsplit(input, indices_or_sections) → List of Tensors
input(Tensor) -張量分裂。
indices_or_sections(Tensor,int或者list或者python的元組:ints) -請參閱
torch.tensor_split()
中的參數。
根據
indices_or_sections
將具有三個或更多維度的張量input
拆分為多個深度方向的張量。每個拆分都是input
的一個視圖。這等效於調用 torch.tensor_split(input, indices_or_sections, dim=2) (拆分維度為 1),除了如果
indices_or_sections
是整數它必須將拆分維度均分,否則運行時錯誤將被拋出。該函數基於 NumPy 的
numpy.dsplit()
。>>> t = torch.arange(16.0).reshape(2, 2, 4) >>> t tensor([[[ 0., 1., 2., 3.], [ 4., 5., 6., 7.]], [[ 8., 9., 10., 11.], [12., 13., 14., 15.]]]) >>> torch.dsplit(t, 2) (tensor([[[ 0., 1.], [ 4., 5.]], [[ 8., 9.], [12., 13.]]]), tensor([[[ 2., 3.], [ 6., 7.]], [[10., 11.], [14., 15.]]]))
>>> torch.dsplit(t, [3, 6]) (tensor([[[ 0., 1., 2.], [ 4., 5., 6.]], [[ 8., 9., 10.], [12., 13., 14.]]]), tensor([[[ 3.], [ 7.]], [[11.], [15.]]]), tensor([], size=(2, 2, 0)))
例子:
參數:
相關用法
- Python PyTorch dstack用法及代碼示例
- Python PyTorch diag用法及代碼示例
- Python PyTorch dirac_用法及代碼示例
- Python PyTorch deform_conv2d用法及代碼示例
- Python PyTorch download_url_to_file用法及代碼示例
- Python PyTorch detect_anomaly用法及代碼示例
- Python PyTorch download_from_url用法及代碼示例
- Python PyTorch dot用法及代碼示例
- Python PyTorch diag_embed用法及代碼示例
- Python PyTorch diff用法及代碼示例
- Python PyTorch diagflat用法及代碼示例
- Python PyTorch div用法及代碼示例
- Python PyTorch diagonal用法及代碼示例
- Python PyTorch dist用法及代碼示例
- Python PyTorch digamma用法及代碼示例
- Python PyTorch deg2rad用法及代碼示例
- Python PyTorch det用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.dsplit。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。