【PyTorch】Tensor&Variable
從重新過一遍PyTorch,記錄會稍晚同步到blog.qhpersonal.top

Initializing a Tensor
Attribute of Tensor
Three attributs is stored: shap, datatype, the device
Tensor and Numpy Conversions
numpy() : Tensor --> Numpy
torch.from_numpy(): Numpy --> Tensor
Operation on Tensor
tensor.to("cuda"): To GPU
cat(): Connect
stack(): Superposition. And stack make the dim up one.
Arithmetic Operations
Multiplication
matrix: tenser @ tensor, tensor.matmul() ? ?// tensor.mm() only use two matrix mul
element-wise product: tensor * tensor, torch.mul()
Others
tensor.sum(): Sum by the specified dim
.item(): single-element tensors --> python numerical value
tensor.add_(): add ? and store the result

參考資料:
[1]Welcome?to?PyTorch Tutorials[EB/OL]. (2022-09-09)[2022-09-09]. https://pytorch.org/tutorials.
標(biāo)簽: