当前位置:网站首页>Learning notes of "hands on learning in depth"

Learning notes of "hands on learning in depth"

2022-07-05 05:05:00 fb_ help

《 Hands-on deep learning 》 Learning notes

Data manipulation

 Insert picture description here

Automatic derivation

Variable setting derivation

x = torch.ones(2, 2, requires_grad=True)

Obtain derivative

out.backward()

Here, the dependent variable is required to be scalar , If tensor, You need to provide a weight matrix with the same size as the dependent variable , The output dependent variable is transformed into a scalar by weighted summation of all elements , Then you can backward().
The reason is well understood : There is no relationship between dependent variables , All dependent variable elements are simply put together , Therefore, their permutation can be regarded as a one-dimensional vector and linearly weighted to a scalar l On . The advantage of this is that the gradient is independent of the latitude of the dependent variable , Got l And the gradient of the independent variable , It doesn't matter what shape the dependent variable is tensor.

Linear regression

The gradient descent method solves the parameters
 Insert picture description here
The above formula can be solved analytically .
 Insert picture description here

The parameters to be solved can also be optimized by gradient descent through linear regression . Small batch random gradient descent is usually used (mini-batch stochastic gradient descent) Method , That is, calculate the average gradient in small batches , Multi batch optimization parameters .
 Insert picture description here
Here is also multiplied by a learning rate , It is equivalent to step size , It can be a little bigger at first , The back should be smaller .

Fully connected layer ( Dense layer )

 Insert picture description here

 Insert picture description here

Linear regression

  1. Build simulation data , Confirm the input (features), Input (label), Parameters
  2. Write data loader( Split data into batch)
  3. structure function (net) , loss And optimization method
  4. iteration epoch solve
     Insert picture description here

Linear regression concise version

  1. data fetch
     Insert picture description here

  2. Define your own function, You need to give the number of parameters and forward function . In fact, it is the functional relationship between input and output . therefore , Give the calculation method of input and output , namely forward function . Neural network replaces this functional relationship with grid structure .
     Insert picture description here

  3. use torch Of net structure
     Insert picture description here

  4. Loss
     Insert picture description here

  5. An optimization method
     Insert picture description here

原网站

版权声明
本文为[fb_ help]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050458475843.html