torch.FloatTensor
时间: 2023-12-02 09:00:28 浏览: 74
torch.FloatTensor is a class in PyTorch that represents a tensor of floating-point numbers. It is a multidimensional array that can hold any number of elements of the same data type (i.e., float).
Here's an example of creating a 2D tensor of floating-point numbers in PyTorch:
```
import torch
# create a 2D tensor of size 3x2
x = torch.FloatTensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
print(x)
```
Output:
```
tensor([[ 1., 2.],
[ 3., 4.],
[ 5., 6.]])
```
In this example, we create a 2D tensor with 3 rows and 2 columns, where each element is a floating-point number. We pass a list of lists of these numbers to the `torch.FloatTensor()` constructor function.
Note that we can perform various operations on this tensor, such as addition, subtraction, multiplication, and division, using PyTorch's built-in functions.
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)