模拟退火算法matlab实现

更新时间:2023-06-20 12:17:04 阅读: 评论:0

文章来源:
www.smatrix/bbs/read.php?tid=5130
模拟退火算法matlab实现
个人自传
复制代码
1. function outPut=Activation_func(x,w)
2. temp=x*w;
3. outPut=temp;
4. [rows cols]=size(temp);
5. for i=1:rows
6.     for j=1:cols
7.         outPut(i,j)=1/(1+exp(-temp(i,j)));
8.     end
9. end
10.
复制代码
1. function outPut=adjust_randWeight(T)
2. outPut=zeros(1);
木命是哪年出生的3. Delta_W=0.5*T*tan(rand(1));
4. outPut=Delta_W;
5. 鱼的单词
复制代码
1. clear
2. %Receive input 练瑜伽可以减肥吗
3. firstLayer_Neural_Num=input('This is the 1st layer.How many neurals do you want to u?  ');
4. condLayer_Neural_Num=input('This is the 2nd layer.How many neurals do you want to u?  ');
5. thirdLayer_Neural_Num=input('This is the 3rd layer.How many neurals do you want to u?  ');
6. %Initialize W and V
7. V=rands(firstLayer_Neural_Num,condLayer_Neural_Num)-0.5;
8. W=rands(condLayer_Neural_Num,thirdLayer_Neural_Num)-0.5;
9. V_copy=V;
10. W_copy=W;
11.
12. %Initialize X and Y
13. X=[0,0;0,1;1,0];
14. Y=[0.6;1;1];
15. [x_rows x_cols]=size(X);
16. [y_rows y_cols]=size(Y);
17. sampNum=x_rows;
18. outputMension=y_cols;
19. %Initialize  Temperature
20. Temperature=10;
21.  
22. %Begin to train
23. while Temperature>0.9
24.     for sampIndex=1:sampNum
25.        
26.         pre_energy=return_energy(X(sampIndex,:),Y(sampIndex,:),V,W);
27.        
28.         %initialize p and r
防火墙怎么打开29.         flag=1;
30.        
31.         %pre_adjustWeight is a 1*4 matrix,which means[state,row,col,value]
32.         %state means if it comes from V ,the state equals 0. Also,if it
33.         % comes from W, the state equals 1.
34.       while flag==1
35.         pre_adjustWeight=generate_randWeight(V,W);
36.         adjust_rows=pre_adjustWeight(2);
37.         adjust_cols=pre_adjustWeight(3);
38.         adjust_val=pre_adjustWeight(4);
太平天国运动死了多少人39.        
40.         %Adjust pre_adjustWeight
41.         Delta_weight=adjust_randWeight(Temperature);
42.         if pre_adjustWeight(1)==0
43.             V_copy(adjust_rows,adjust_cols)=adjust_val+Delta_weight;
44.         el
45.             W_copy(adjust_rows,adjust_cols)=adjust_val+Delta_weight;
46.         end
47.            
48.         pro_energy=return_energy(X,Y,V_copy,W_copy);
49.        
50.         Delta_energy=pro_energy-pre_energy;
51.        
52.         if Delta_energy>0
53.             r=rand(1);
54.             p=Temperature/(Temperature^2+pro_energy^2);
55.             if p<r
56.                 flag=0;
57.             end   
58.         end
59.       end
60. 宽带接口   
61.         if pre_adjustWeight(1)==0
62.             V(adjust_rows,adjust_cols)=adjust_val+Delta_weight;
63.         el
64.             W(adjust_rows,adjust_cols)=adjust_val+Delta_weight;
65.         end
大字的成语66.      
67.        
68.     end
69.     Temperature=0.9*Temperature;
70.    
71. end
72.

本文发布于:2023-06-20 12:17:04,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1046863.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:来源   算法   复制   木命   瑜伽   防火墙   接口   成语
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图