当前位置:网站首页>leetcode——83,24; Machine learning - neural networks
leetcode——83,24; Machine learning - neural networks
2022-07-27 13:32:00 【Anan.3】
83. Delete duplicate elements from the sort list

Ideas :
According to the title, we can get the title as ordered linked list , With a pointer p Point to the head node , Start from his direct successor node and find the node with the same value , After finding it, assign the next value to the next ; And so on ,p When pointing to the last node, the algorithm ends .
Code :
struct ListNode* deleteDuplicates(struct ListNode* head){
if(head==NULL){
return head;
}
struct ListNode *p=head;
while(p->next!=NULL){
if(p->val==p->next->val){
p->next=p->next->next;
}else{
p=p->next;
}
}
return head;
}
24. Two or two exchange nodes in a linked list

Ideas :
Define three pointers ,p,q,t;p Point to the first node of the adjacent node ,q Point to the second node of the adjacent node ,t Point to p, To connect the previous group of adjacent nodes with the next adjacent node .
And then use p,q swapping , then t Point to the first of the next set of nodes
struct ListNode* swapPairs(struct ListNode* head){
if(head==NULL || head->next==NULL){
return head;
}
struct ListNode *p=head,*t=NULL;
struct ListNode *q=p->next,*rp=q;
while(p->next!=NULL){
p->next=q->next;
q->next=p;
if(t!=NULL){
t->next=q;
}
t=p;
p=p->next;
if(p==NULL){
break;
}
q=p->next;
}
return q;
}
The function of activation
Activation function is an important part of neural network . If you don't activate the function ( That is, the activation function is f(x)=x), under these circumstances , The input of each layer of the network is the linear output of the previous layer , therefore , No matter how many layers the neural network has , The final output is a linear combination of inputs , Equivalent to the effect of no hidden layer , This is the original perceptron .
Transform linear problems into nonlinear .
The basic process of machine learning
0 Raise questions
Most machine learning processes first ask a question , This problem cannot be solved by simple conditional procedures or rule-based engines ( expert system ) To answer . The answers to these questions are usually related to the prediction results of the data set .
1 Collect and prepare data
In order to solve this problem , We need data related to the problem . The quality and quantity of data will determine the accuracy of prediction results . Data visualization is an important aspect of this link . At this stage, the data is also divided into training set, test set and verification set to build the model , With 6.1.3 To distribute .
2 Choose the training method
Depending on the nature of the problem and the data , We need to choose the appropriate training model to best adapt to the data and obtain accurate prediction results .
3 Training models
Import training data , We will use various algorithms to train the model to identify patterns in the data . The model can take advantage of internally adjustable weights , Prioritize some parts of the data over others , To build a better model .
4 Evaluation model
Use test sets ( Data not involved in model training ) To see the performance of the model ,
5 forecast Import new input values into the model to test the accuracy of the model
The three-layer feedforward neural network has an input layer 、 Output layer 、 Hidden layer for training
The validation model can be based on P-R curve 、ROC、AUC etc.
The difference between verification set and training set
Training set : Data samples for model fitting , That is, the sample set used for training , It is mainly used to train the parameters of neural network .
Verification set : The sample set left alone in the process of model training , It can be used to adjust the super parameters of the model and to preliminarily evaluate the capability of the model .
Test set : Used to evaluate the generalization ability of the final model . But not as a parameter 、 The basis of selection related to algorithms such as feature selection .
P1: The role of training sets
Fitting model , Adjust the network weight .
P2: The role of the validation set
effect 1: Quickly adjust parameters , That is, we can select the super parameter through the verification set ( Network layers 、 Number of network nodes 、 The number of iterations epoch、 Learning rate learning rate、 Optimizer ) etc. .
effect 2: Select the super parameter , In order to make our model perform better in the test set , Tuning parameters is an inevitable part , If the test set is regarded as the verification set , Adjust parameters to fit the test set , Is infeasible , This is equivalent to cheating .
effect 3: Monitor whether the model is normal
The importance of validation sets :
If the validation set is not set , We usually have to wait until the test set to know the real strength of our model , Then adjust the parameters , This time cost is higher , Through the verification set, we can train several epoch Then check the training effect of the model and whether our network is abnormal , Then decide how to adjust our super parameters .
边栏推荐
猜你喜欢

SCI论文写作

What should I do if I can't see any tiles on SAP Fiori launchpad?

使用碳刷的注意事项有哪些

3D laser slam:aloam---ceres optimization part and code analysis

W3School导航栏练习

面试官常问:如何手撸一个“消息队列”和“延迟消息队列”?

Pat class B 1109 good at C (detailed)

AMD Adrenalin 22.7.1 驱动更新:OpenGL 性能翻倍,支持微软 Win11 22H2 系统
![[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (IX)](/img/cf/44b3983dd5d5f7b92d90d918215908.png)
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (IX)

How to debug JNI program
随机推荐
Hierarchy of elements
Arrays and functions of knowledge in every corner of C language
插入排序,正序,倒序
51:第五章:开发admin管理服务:4:开发【新增admin账号,接口】;(只开发了【用户名+密码的,方式】;【@T…】注解控制事务;设置cookie时,是否需要使用URLEncoder去编码;)
Fixed positioning
从tidb实时同步到mysql 只能用 tidb binlog 工具吗?
滑环设备怎么进行维护
52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte
W3School导航栏练习
Go语言系列:如何搭建Go语言开发环境?
AMD Adrenalin 22.7.1 驱动更新:OpenGL 性能翻倍,支持微软 Win11 22H2 系统
uniapp防止连续点击出错
Cute image classification -- a general explanation of the article "what are the common flops in CNN model?"
C# FTP增、删、改、查、创建多级目录、自动重连、切换目录
Connotative quotations
Application for the latest version of Pan domain name certificate
【2023复旦微电子提前批笔试题】~ 题目及参考答案
Icon Font
libevent 之 evconnlistener_new_bind
QT excellent open source project 13: qscintilla