% 生成訓練樣本集
clear all;
clc;
P=[110 0.807 240 0.2 15 1 18 2 1.5;
110 2.865 240 0.1 15 2 12 1 2;
110 2.59 240 0.1 12 4 24 1 1.5;
220 0.6 240 0.3 12 3 18 2 1;
220 3 240 0.3 25 3 21 1 1.5;
110 1.562 240 0.3 15 3 18 1 1.5;
110 0.547 240 0.3 15 1 9 2 1.5];
0 1.318 300 0.1 15 2 18 1 2];
T=[54248 162787 168380 314797;
28614 63958 69637 82898;
86002 402710 644415 328084;
230802 445102 362823 335913;
60257 127892 76753 73541;
34615 93532 80762 110049;
56783 172907 164548 144040];
@907 117437 120368 130179];
m=max(max(P));
n=max(max(T));
P=P'/m;
T=T'/n;
%-------------------------------------------------------------------------%
pr(1:9,1)=0; %輸入矢量的取值范圍矩陣
pr(1:9,2)=1;
bpnet=newff(pr,[12 4],{'logsig', 'logsig'}, 'traingdx', 'learngdm');
%建立BP神經網絡, 12個隱層神經元,4個輸出神經元
%tranferFcn屬性 'logsig' 隱層采用Sigmoid傳輸函數
%tranferFcn屬性 'logsig' 輸出層采用Sigmoid傳輸函數
%trainFcn屬性 'traingdx' 自適應調整學習速率附加動量因子梯度下降反向傳播算法訓練函數
%learn屬性 'learngdm' 附加動量因子的梯度下降學習函數
net.trainParam.epochs=1000;%允許最大訓練步數2000步
net.trainParam.goal=0.001; %訓練目標最小誤差0.001
net.trainParam.show=10; %每間隔100步顯示一次訓練結果
net.trainParam.lr=0.05; %學習速率0.05
bpnet=train(bpnet,P,T);
%-------------------------------------------------------------------------
p=[110 1.318 300 0.1 15 2 18 1 2];
p=p'/m;
r=sim(bpnet,p);
R=r'*n;
display(R);
標簽:
2013
算法
工具箱
上傳時間:
2016-05-28
上傳用戶:shanqiu
1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and
another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.)
#include<stdio.h>
#include<stdlib.h>
void merge(int arr[],int low,int mid,int high){
int i,k;
int *tmp=(int*)malloc((high-low+1)*sizeof(int));
int left_low=low;
int left_high=mid;
int right_low=mid+1;
int right_high=high;
for(k=0;left_low<=left_high&&right_low<=right_high;k++)
{
if(arr[left_low]<=arr[right_low]){
tmp[k]=arr[left_low++];
}
else{
tmp[k]=arr[right_low++];
}
}
if(left_low<=left_high){
for(i=left_low;i<=left_high;i++){
tmp[k++]=arr[i];
}
}
if(right_low<=right_high){
for(i=right_low;i<=right_high;i++)
tmp[k++]=arr[i];
}
for(i=0;i<high-low+1;i++)
arr[low+i]=tmp[i];
}
void merge_sort(int a[],int p,int r){
int q;
if(p<r){
q=(p+r)/2;
merge_sort(a,p,q);
merge_sort(a,q+1,r);
merge(a,p,q,r);
}
}
int main(){
int a[8]={3,5,8,6,4,1,1};
int i,j;
int x=10;
merge_sort(a,0,6);
printf("after Merging-Sort:\n");
for(i=0;i<7;i++){
printf("%d",a[i]);
}
printf("\n");
i=0;j=6;
do{
if(a[i]+a[j]==x){
printf("exist");
break;
}
if(a[i]+a[j]>x)
j--;
if(a[i]+a[j]<x)
i++;
}while(i<=j);
if(i>j)
printf("not exist");
system("pause");
return 0;
}
標簽:
c語言
算法
排序
上傳時間:
2017-04-01
上傳用戶:糖兒水嘻嘻
RSA算法 :首先, 找出三個數, p, q, r, 其中 p, q 是兩個相異的質數, r 是與 (p-1)(q-1) 互質的數...... p, q, r 這三個數便是 person_key,接著, 找出 m, 使得 r^m == 1 mod (p-1)(q-1)..... 這個 m 一定存在, 因為 r 與 (p-1)(q-1) 互質, 用輾轉相除法就可以得到了..... 再來, 計算 n = pq....... m, n 這兩個數便是 public_key ,編碼過程是, 若資料為 a, 將其看成是一個大整數, 假設 a < n.... 如果 a >= n 的話, 就將 a 表成 s 進位 (s
標簽:
person_key
RSA
算法
上傳時間:
2013-12-14
上傳用戶:zhuyibin