1.CSV turn Matix
import pandas as pd
dat = pd.read.csv('path')
dat_matrix = df.values
2.Matrix sliced
dat_m_0 = dat_matrix[:,1] #截取矩阵中第二列所有数据
dat_m_1 = dat_matrix[:,1:5] #截取矩阵中第一至四列所有数据
dat_m_2 = dat_matrix[1,:] #截取矩阵中第二行所有数据
dat_m_3 = dat_matrix[1:5,:] #截取矩阵中第二至四行所有数据
3.Matrix turn torch
dat_array = np.array(dat_matrix)
dat_torch = torch.from_numpy(dat_array)
4.torch data type change
dat_t_float = dat_torch.float()
dat_t_long = dat_torch.long()
dat_t_int32 = dat_torch.int()
5. With regard to the number of neurons
- 1. The number of neurons required dimension corresponding to the number of the input data
- 2. The output neurons corresponding to the category
6. For the loss function
- 1.CrossEntropy (), y data required training must be long type
- 2.MSELoss (), y data requires training to be a float
Reproduced in: https: //www.jianshu.com/p/1412a9995f01