update tensors.py
This commit is contained in:
parent
32fec1e081
commit
adf6365438
1 changed files with 4 additions and 4 deletions
|
@ -34,9 +34,9 @@ print(f"Zeros: \n {zeros_tensor} \n")
|
||||||
|
|
||||||
tensor_attr = torch.rand(3,4).to('xpu')
|
tensor_attr = torch.rand(3,4).to('xpu')
|
||||||
|
|
||||||
# print(f"Shape: {tensor_attr.shape}")
|
print(f"Shape: {tensor_attr.shape}")
|
||||||
# print(f"Datatype: {tensor_attr.dtype}")
|
print(f"Datatype: {tensor_attr.dtype}")
|
||||||
# print(f"Device: {tensor_attr.device}")
|
print(f"Device: {tensor_attr.device}")
|
||||||
|
|
||||||
# indexing & slicing
|
# indexing & slicing
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ y3 = torch.rand_like(y1) # create a new tensor with same shape as y1
|
||||||
torch.matmul(tensor, tensor.T, out=y3)
|
torch.matmul(tensor, tensor.T, out=y3)
|
||||||
|
|
||||||
|
|
||||||
# comput the element-wise product (z1, z2, z3 will have same values)
|
# compute the element-wise product (z1, z2, z3 will have same values)
|
||||||
z1 = tensor * tensor
|
z1 = tensor * tensor
|
||||||
z2 = tensor.mul(tensor)
|
z2 = tensor.mul(tensor)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue