I’m converting a `numpy.array`

to a torch tensor:

`a = torch.from_numpy(np.random.rand(1,5))`

And I want to it to have this type `torch.get_default_dtype()`

How do you do that? thanks

I’m converting a `numpy.array`

to a torch tensor:

`a = torch.from_numpy(np.random.rand(1,5))`

And I want to it to have this type `torch.get_default_dtype()`

How do you do that? thanks

You can use `.type()`

function to specify the type.

```
a = torch.from_numpy(np.random.rand(1.5)).type(torch.get_default_dtype())
```

1 Like

I was sure I checked this option… anyway this is it, thanks!