本文簡要介紹python語言中 torch.broadcast_tensors
的用法。
用法:
torch.broadcast_tensors(*tensors) → List of Tensors
*tensors-任意數量的相同類型的張量
根據廣播語義廣播給定的張量。
警告
廣播張量的多個元素可能引用單個內存位置。因此,就地操作(尤其是矢量化的操作)可能會導致不正確的行為。如果您需要寫入張量,請先克隆它們。
例子:
>>> x = torch.arange(3).view(1, 3) >>> y = torch.arange(2).view(2, 1) >>> a, b = torch.broadcast_tensors(x, y) >>> a.size() torch.Size([2, 3]) >>> a tensor([[0, 1, 2], [0, 1, 2]])
參數:
相關用法
- Python PyTorch broadcast_to用法及代碼示例
- Python PyTorch broadcast_object_list用法及代碼示例
- Python PyTorch broadcast_shapes用法及代碼示例
- Python PyTorch bincount用法及代碼示例
- Python PyTorch bitwise_right_shift用法及代碼示例
- Python PyTorch bernoulli用法及代碼示例
- Python PyTorch bitwise_and用法及代碼示例
- Python PyTorch bitwise_not用法及代碼示例
- Python PyTorch backward用法及代碼示例
- Python PyTorch batched_powerSGD_hook用法及代碼示例
- Python PyTorch binary_cross_entropy用法及代碼示例
- Python PyTorch bitwise_xor用法及代碼示例
- Python PyTorch binary_cross_entropy_with_logits用法及代碼示例
- Python PyTorch bleu_score用法及代碼示例
- Python PyTorch build_vocab_from_iterator用法及代碼示例
- Python PyTorch bitwise_or用法及代碼示例
- Python PyTorch bitwise_left_shift用法及代碼示例
- Python PyTorch bf16_compress_wrapper用法及代碼示例
- Python PyTorch bmm用法及代碼示例
- Python PyTorch baddbmm用法及代碼示例
- Python PyTorch bf16_compress_hook用法及代碼示例
- Python PyTorch bucketize用法及代碼示例
- Python PyTorch block_diag用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.broadcast_tensors。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。