


torch.tensor(1)               # scalar
tensor(1)
torch.tensor([1, 2.3]).dtype  # type inferece
torch.float32
torch.tensor([1, 2]).dtype    # type inferece
torch.int64
```



We've also added more tensor creation methods. Some of them have torch.*_like and/or tensor.new_* variants.

torch.*_like takes in an input Tensor instead of a shape. It returns a Tensor with same attributes as the input Tensor by default unless otherwise specified:

```python



x = torch.randn(3, dtype=torch.float64)
torch.zeros_like(x)
 tensor([ 0.,  0.,  0.], dtype=torch.float64)
torch.zeros_like(x, dtype=torch.int)
 tensor([ 0,  0,  0], dtype=torch.int32)
  ```




tensor.new_* can also create Tensors with same attributes as tensor, but it always takes in a shape argument:

```python



x = torch.randn(3, dtype=torch.float64)
x.new_ones(2)
 tensor([ 1.,  1.], dtype=torch.float64)
x.new_ones(4, dtype=torch.int)
 tensor([ 1,  1,  1,  1], dtype=torch.int32)
  ```


