deep learning(1)BP神经网络原理与练习
具体原理参考如下讲义:
1、神经网络
2、反向传导
看完材料1和2就可以梳理清楚bp神经网络的基本工作原理,下面通过一个C语言实现的程序来练习这个算法
//Backpropagation, 25x25x8 units, binary sigmoid function network
//Written by Thomas Riga, University of Genoa, Italy
//thomas@magister.magi.unige.it #include <iostream>
#include <fstream>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <stdio.h>
#include <float.h>
using namespace std; double **input,
*hidden,
**output,
**target,
*bias,
**weight_i_h,
**weight_h_o,
*errorsignal_hidden,
*errorsignal_output; int input_array_size,
hidden_array_size,
output_array_size,
max_patterns,
bias_array_size,
gaset = -,
number_of_input_patterns,
pattern,
file_loaded = ,
ytemp = ,
ztemp = ;
double learning_rate,
max_error_tollerance = 0.1;
char filename[];
#define IA 16807
#define IM 2147483647
#define AM (1.0 / IM)
#define IQ 127773
#define IR 2836
#define NTAB 32
#define NDIV (1+(IM-1) / NTAB)
#define EPS 1.2e-7
#define RNMX (1.0 - EPS)
int compare_output_to_target();
void load_data(char *arg);
void save_data(char *argres);
void forward_pass(int pattern);
void backward_pass(int pattern);
void custom();
void compute_output_pattern();
void get_file_name();
float bedlam(long *idum);
void learn();
void make();
void test();
void print_data();
void print_data_to_screen();
void print_data_to_file();
void output_to_screen();
int getnumber();
void change_learning_rate();
void initialize_net();
void clear_memory(); int main()
{
cout << "backpropagation network by Thomas Riga, University of Genoa, Italy" << endl;
for(;;) {
char choice;
cout << endl << "1. load data" << endl;
cout << "2. learn from data" << endl;
cout << "3. compute output pattern" << endl;
cout << "4. make new data file" << endl;
cout << "5. save data" << endl;
cout << "6. print data" << endl;
cout << "7. change learning rate" << endl;
cout << "8. exit" << endl << endl;
cout << "Enter your choice (1-8)";
do { choice = getch(); } while (choice != '' && choice != '' && choice != '' && choice != '' && choice != '' && choice != '' && choice != '' && choice != '');
switch(choice) {
case '':
{
if (file_loaded == ) clear_memory();
get_file_name();
file_loaded = ;
load_data(filename);
}
break;
case '': learn();
break;
case '': compute_output_pattern();
break;
case '': make();
break;
case '':
{
if (file_loaded == )
{
cout << endl
<< "there is no data loaded into memory"
<< endl;
break;
}
cout << endl << "enter a filename to save data to: ";
cin >> filename;
save_data(filename);
}
break;
case '': print_data();
break;
case '': change_learning_rate();
break;
case '': return ;
};
}
} void initialize_net()
{
int x;
input = new double * [number_of_input_patterns];
if(!input) { cout << endl << "memory problem!"; exit(); }
for(x=; x<number_of_input_patterns; x++)
{
input[x] = new double [input_array_size];
if(!input[x]) { cout << endl << "memory problem!"; exit(); }
}
hidden = new double [hidden_array_size];
if(!hidden) { cout << endl << "memory problem!"; exit(); }
output = new double * [number_of_input_patterns];
if(!output) { cout << endl << "memory problem!"; exit(); }
for(x=; x<number_of_input_patterns; x++)
{
output[x] = new double [output_array_size];
if(!output[x]) { cout << endl << "memory problem!"; exit(); }
}
target = new double * [number_of_input_patterns];
if(!target) { cout << endl << "memory problem!"; exit(); }
for(x=; x<number_of_input_patterns; x++)
{
target[x] = new double [output_array_size];
if(!target[x]) { cout << endl << "memory problem!"; exit(); }
}
bias = new double [bias_array_size];
if(!bias) { cout << endl << "memory problem!"; exit(); }
weight_i_h = new double * [input_array_size];
if(!weight_i_h) { cout << endl << "memory problem!"; exit(); }
for(x=; x<input_array_size; x++)
{
weight_i_h[x] = new double [hidden_array_size];
if(!weight_i_h[x]) { cout << endl << "memory problem!"; exit(); }
}
weight_h_o = new double * [hidden_array_size];
if(!weight_h_o) { cout << endl << "memory problem!"; exit(); }
for(x=; x<hidden_array_size; x++)
{
weight_h_o[x] = new double [output_array_size];
if(!weight_h_o[x]) { cout << endl << "memory problem!"; exit(); }
}
errorsignal_hidden = new double [hidden_array_size];
if(!errorsignal_hidden) { cout << endl << "memory problem!"; exit(); }
errorsignal_output = new double [output_array_size];
if(!errorsignal_output) { cout << endl << "memory problem!"; exit(); }
return;
} void learn()
{
if (file_loaded == )
{
cout << endl
<< "there is no data loaded into memory"
<< endl;
return;
}
cout << endl << "learning..." << endl << "press a key to return to menu" << endl;
register int y;
while(!kbhit()) {
for(y=; y<number_of_input_patterns; y++) {
forward_pass(y);
backward_pass(y);
}
if(compare_output_to_target()) {
cout << endl << "learning successful" << endl;
return;
} }
cout << endl << "learning not successful yet" << endl;
return;
} void load_data(char *arg) {
int x, y;
ifstream in(arg);
if(!in) { cout << endl << "failed to load data file" << endl; file_loaded = ; return; }
in >> input_array_size;
in >> hidden_array_size;
in >> output_array_size;
in >> learning_rate;
in >> number_of_input_patterns;
bias_array_size = hidden_array_size + output_array_size;
initialize_net();
for(x = ; x < bias_array_size; x++) in >> bias[x];
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) in >> weight_i_h[x][y];
}
for(x = ; x < hidden_array_size; x++) {
for(y=; y<output_array_size; y++) in >> weight_h_o[x][y];
}
for(x=; x < number_of_input_patterns; x++) {
for(y=; y<input_array_size; y++) in >> input[x][y];
}
for(x=; x < number_of_input_patterns; x++) {
for(y=; y<output_array_size; y++) in >> target[x][y];
}
in.close();
cout << endl << "data loaded" << endl;
return;
} void forward_pass(int pattern)
{
_control87(MCW_EM, MCW_EM);
register double temp=;
register int x,y; // INPUT -> HIDDEN
for(y=; y<hidden_array_size; y++) {
for(x=; x<input_array_size; x++) {
temp += (input[pattern][x] * weight_i_h[x][y]);
}
hidden[y] = (1.0 / (1.0 + exp(-1.0 * (temp + bias[y]))));
temp = ;
} // HIDDEN -> OUTPUT
for(y=; y<output_array_size; y++) {
for(x=; x<hidden_array_size; x++) {
temp += (hidden[x] * weight_h_o[x][y]);
}
output[pattern][y] = (1.0 / (1.0 + exp(-1.0 * (temp + bias[y + hidden_array_size]))));
temp = ;
}
return;
} void backward_pass(int pattern)
{
register int x, y;
register double temp = ; // COMPUTE ERRORSIGNAL FOR OUTPUT UNITS
for(x=; x<output_array_size; x++) {
errorsignal_output[x] = (target[pattern][x] - output[pattern][x]);
} // COMPUTE ERRORSIGNAL FOR HIDDEN UNITS
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) {
temp += (errorsignal_output[y] * weight_h_o[x][y]);
}
errorsignal_hidden[x] = hidden[x] * (-hidden[x]) * temp;
temp = 0.0;
} // ADJUST WEIGHTS OF CONNECTIONS FROM HIDDEN TO OUTPUT UNITS
double length = 0.0;
for (x=; x<hidden_array_size; x++) {
length += hidden[x]*hidden[x];
}
if (length<=0.1) length = 0.1;
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) {
weight_h_o[x][y] += (learning_rate * errorsignal_output[y] *
hidden[x]/length);
}
} // ADJUST BIASES OF HIDDEN UNITS
for(x=hidden_array_size; x<bias_array_size; x++) {
bias[x] += (learning_rate * errorsignal_output[x] / length);
} // ADJUST WEIGHTS OF CONNECTIONS FROM INPUT TO HIDDEN UNITS
length = 0.0;
for (x=; x<input_array_size; x++) {
length += input[pattern][x]*input[pattern][x];
}
if (length<=0.1) length = 0.1;
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) {
weight_i_h[x][y] += (learning_rate * errorsignal_hidden[y] *
input[pattern][x]/length);
}
} // ADJUST BIASES FOR OUTPUT UNITS
for(x=; x<hidden_array_size; x++) {
bias[x] += (learning_rate * errorsignal_hidden[x] / length);
}
return;
} int compare_output_to_target()
{
register int y,z;
register double temp, error = 0.0;
temp = target[ytemp][ztemp] - output[ytemp][ztemp];
if (temp < ) error -= temp;
else error += temp;
if(error > max_error_tollerance) return ;
error = 0.0;
for(y=; y < number_of_input_patterns; y++) {
for(z=; z < output_array_size; z++) {
temp = target[y][z] - output[y][z];
if (temp < ) error -= temp;
else error += temp;
if(error > max_error_tollerance) {
ytemp = y;
ztemp = z;
return ;
}
error = 0.0;
}
}
return ;
} void save_data(char *argres) {
int x, y;
ofstream out;
out.open(argres);
if(!out) { cout << endl << "failed to save file" << endl; return; }
out << input_array_size << endl;
out << hidden_array_size << endl;
out << output_array_size << endl;
out << learning_rate << endl;
out << number_of_input_patterns << endl << endl;
for(x=; x<bias_array_size; x++) out << bias[x] << ' ';
out << endl << endl;
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) out << weight_i_h[x][y] << ' ';
}
out << endl << endl;
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) out << weight_h_o[x][y] << ' ';
}
out << endl << endl;
for(x=; x<number_of_input_patterns; x++) {
for(y=; y<input_array_size; y++) out << input[x][y] << ' ';
out << endl;
}
out << endl;
for(x=; x<number_of_input_patterns; x++) {
for(y=; y<output_array_size; y++) out << target[x][y] << ' ';
out << endl;
}
out.close();
cout << endl << "data saved" << endl;
return;
} void make()
{
int x, y, z;
double inpx, bias_array_size, input_array_size, hidden_array_size, output_array_size;
char makefilename[];
cout << endl << "enter name of new data file: ";
cin >> makefilename;
ofstream out;
out.open(makefilename);
if(!out) { cout << endl << "failed to open file" << endl; return;}
cout << "how many input units? ";
cin >> input_array_size;
out << input_array_size << endl;
cout << "how many hidden units? ";
cin >> hidden_array_size;
out << hidden_array_size << endl;
cout << "how many output units? ";
cin >> output_array_size;
out << output_array_size << endl;
bias_array_size = hidden_array_size + output_array_size;
cout << endl << "Learning rate: ";
cin >> inpx;
out << inpx << endl;
cout << endl << "Number of input patterns: ";
cin >> z;
out << z << endl << endl;
for(x=; x<bias_array_size; x++) out << (1.0 - (2.0 * bedlam((long*)(gaset)))) << ' ';
out << endl << endl;
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) out << (1.0 - (2.0 * bedlam((long*)(gaset)))) << ' ';
}
out << endl << endl;
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) out << (1.0 - (2.0 * bedlam((long*)(gaset)))) << ' ';
}
out << endl << endl;
for(x=; x < z; x++) {
cout << endl << "input pattern " << (x + ) << endl;
for(y=; y<input_array_size; y++) {
cout << (y+) << ": ";
cin >> inpx;
out << inpx << ' ';
}
out << endl;
}
out << endl;
for(x=; x < z; x++) {
cout << endl << "target output pattern " << (x+) << endl;
for(y=; y<output_array_size; y++) {
cout << (y+) << ": ";
cin >> inpx;
out << inpx << ' ';
}
out << endl;
}
out.close();
cout << endl << "data saved, to work with this new data file you first have to load it" << endl;
return;
} float bedlam(long *idum)
{
int xj;
long xk;
static long iy=;
static long iv[NTAB];
float temp; if(*idum <= || !iy)
{
if(-(*idum) < )
{
*idum = + *idum;
}
else
{
*idum = -(*idum);
}
for(xj = NTAB+; xj >= ; xj--)
{
xk = (*idum) / IQ;
*idum = IA * (*idum - xk * IQ) - IR * xk;
if(*idum < )
{
*idum += IM;
}
if(xj < NTAB)
{
iv[xj] = *idum;
}
}
iy = iv[];
} xk = (*idum) / IQ;
*idum = IA * (*idum - xk * IQ) - IR * xk;
if(*idum < )
{
*idum += IM;
}
xj = iy / NDIV;
iy = iv[xj];
iv[xj] = *idum; if((temp=AM*iy) > RNMX)
{
return(RNMX);
}
else
{
return(temp);
}
} void test()
{
pattern = ;
while(pattern == ) {
cout << endl << endl << "There are " << number_of_input_patterns << " input patterns in the file," << endl << "enter a number within this range: ";
pattern = getnumber();
}
pattern--;
forward_pass(pattern);
output_to_screen();
return;
} void output_to_screen()
{
int x;
cout << endl << "Output pattern:" << endl;
for(x=; x<output_array_size; x++) {
cout << endl << (x+) << ": " << output[pattern][x] << " binary: ";
if(output[pattern][x] >= 0.9) cout << "";
else if(output[pattern][x]<=0.1) cout << "";
else cout << "intermediate value";
}
cout << endl;
return;
} int getnumber()
{
int a, b = ;
char c, d[];
while(b<) {
do { c = getch(); } while (c != '' && c != '' && c != '' && c != '' && c != '' && c != '' && c != '' && c != '' && c != '' && c != '' && toascii(c) != );
if(toascii(c)==) break;
if(toascii(c)==) return ;
d[b] = c;
cout << c;
b++;
}
d[b] = '\0';
a = atoi(d);
if(a < || a > number_of_input_patterns) a = ;
return a;
} void get_file_name()
{
cout << endl << "enter name of file to load: ";
cin >> filename;
return;
} void print_data()
{
char choice;
if (file_loaded == )
{
cout << endl
<< "there is no data loaded into memory"
<< endl;
return;
}
cout << endl << "1. print data to screen" << endl;
cout << "2. print data to file" << endl;
cout << "3. return to main menu" << endl << endl;
cout << "Enter your choice (1-3)" << endl;
do { choice = getch(); } while (choice != '' && choice != '' && choice != '');
switch(choice) {
case '': print_data_to_screen();
break;
case '': print_data_to_file();
break;
case '': return;
};
return;
} void print_data_to_screen() {
register int x, y;
cout << endl << endl << "DATA FILE: " << filename << endl;
cout << "learning rate: " << learning_rate << endl;
cout << "input units: " << input_array_size << endl;
cout << "hidden units: " << hidden_array_size << endl;
cout << "output units: " << output_array_size << endl;
cout << "number of input and target output patterns: " << number_of_input_patterns << endl << endl;
cout << "INPUT AND TARGET OUTPUT PATTERNS:";
for(x=; x<number_of_input_patterns; x++) {
cout << endl << "input pattern: " << (x+) << endl;
for(y=; y<input_array_size; y++) cout << input[x][y] << " ";
cout << endl << "target output pattern: " << (x+) << endl;
for(y=; y<output_array_size; y++) cout << target[x][y] << " ";
}
cout << endl << endl << "BIASES:" << endl;
for(x=; x<hidden_array_size; x++) {
cout << "bias of hidden unit " << (x+) << ": " << bias[x];
if(x<output_array_size) cout << " bias of output unit " << (x+) << ": " << bias[x+hidden_array_size];
cout << endl;
}
cout << endl << "WEIGHTS:" << endl;
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) cout << "i_h[" << x << "][" << y << "]: " << weight_i_h[x][y] << endl;
}
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) cout << "h_o[" << x << "][" << y << "]: " << weight_h_o[x][y] << endl;
}
return;
} void print_data_to_file()
{
char printfile[];
cout << endl << "enter name of file to print data to: ";
cin >> printfile;
ofstream out;
out.open(printfile);
if(!out) { cout << endl << "failed to open file"; return; }
register int x, y;
out << endl << endl << "DATA FILE: " << filename << endl;
out << "input units: " << input_array_size << endl;
out << "hidden units: " << hidden_array_size << endl;
out << "output units: " << output_array_size << endl;
out << "learning rate: " << learning_rate << endl;
out << "number of input and target output patterns: " << number_of_input_patterns << endl << endl;
out << "INPUT AND TARGET OUTPUT PATTERNS:";
for(x=; x<number_of_input_patterns; x++) {
out << endl << "input pattern: " << (x+) << endl;
for(y=; y<input_array_size; y++) out << input[x][y] << " ";
out << endl << "target output pattern: " << (x+) << endl;
for(y=; y<output_array_size; y++) out << target[x][y] << " ";
}
out << endl << endl << "BIASES:" << endl;
for(x=; x<hidden_array_size; x++) {
out << "bias of hidden unit " << (x+) << ": " << bias[x];
if(x<output_array_size) out << " bias of output unit " << (x+) << ": " << bias[x+hidden_array_size];
out << endl;
}
out << endl << "WEIGHTS:" << endl;
for(x=; x<input_array_size; x++) {
for(y=; y<hidden_array_size; y++) out << "i_h[" << x << "][" << y << "]: " << weight_i_h[x][y] << endl;
}
for(x=; x<hidden_array_size; x++) {
for(y=; y<output_array_size; y++) out << "h_o[" << x << "][" << y << "]: " << weight_h_o[x][y] << endl;
}
out.close();
cout << endl << "data has been printed to " << printfile << endl;
return;
} void change_learning_rate()
{
if (file_loaded == )
{
cout << endl
<< "there is no data loaded into memory"
<< endl;
return;
}
cout << endl << "actual learning rate: " << learning_rate << " new value: ";
cin >> learning_rate;
return;
} void compute_output_pattern()
{
if (file_loaded == )
{
cout << endl
<< "there is no data loaded into memory"
<< endl;
return;
}
char choice;
cout << endl << endl << "1. load trained input pattern into network" << endl;
cout << "2. load custom input pattern into network" << endl;
cout << "3. go back to main menu" << endl << endl;
cout << "Enter your choice (1-3)" << endl;
do { choice = getch(); } while (choice != '' && choice != '' && choice != '');
switch(choice) {
case '': test();
break;
case '': custom();
break;
case '': return;
};
} void custom()
{
_control87 (MCW_EM, MCW_EM);
char filename[];
register double temp=;
register int x,y;
double *custom_input = new double [input_array_size];
if(!custom_input)
{
cout << endl << "memory problem!";
return;
}
double *custom_output = new double [output_array_size];
if(!custom_output)
{
delete [] custom_input;
cout << endl << "memory problem!";
return;
}
cout << endl << endl << "enter file that contains test input pattern: ";
cin >> filename;
ifstream in(filename);
if(!in) { cout << endl << "failed to load data file" << endl; return; }
for(x = ; x < input_array_size; x++) {
in >> custom_input[x];
}
for(y=; y<hidden_array_size; y++) {
for(x=; x<input_array_size; x++) {
temp += (custom_input[x] * weight_i_h[x][y]);
}
hidden[y] = (1.0 / (1.0 + exp(-1.0 * (temp + bias[y]))));
temp = ;
}
for(y=; y<output_array_size; y++) {
for(x=; x<hidden_array_size; x++) {
temp += (hidden[x] * weight_h_o[x][y]);
}
custom_output[y] = (1.0 / (1.0 + exp(-1.0 * (temp + bias[y + hidden_array_size]))));
temp = ;
}
cout << endl << "Input pattern:" << endl;
for(x = ; x < input_array_size; x++) {
cout << "[" << (x + ) << ": " << custom_input[x] << "] ";
}
cout << endl << endl << "Output pattern:";
for(x=; x<output_array_size; x++) {
cout << endl << (x+) << ": " << custom_output[x] << " binary: ";
if(custom_output[x] >= 0.9) cout << "";
else if(custom_output[x]<=0.1) cout << "";
else cout << "intermediate value";
}
cout << endl;
delete [] custom_input;
delete [] custom_output;
return;
} void clear_memory()
{
int x;
for(x=; x<number_of_input_patterns; x++)
{
delete [] input[x];
}
delete [] input;
delete [] hidden;
for(x=; x<number_of_input_patterns; x++)
{
delete [] output[x];
}
delete [] output;
for(x=; x<number_of_input_patterns; x++)
{
delete [] target[x];
}
delete [] target;
delete [] bias;
for(x=; x<input_array_size; x++)
{
delete [] weight_i_h[x];
}
delete [] weight_i_h;
for(x=; x<hidden_array_size; x++)
{
delete [] weight_h_o[x];
}
delete [] weight_h_o;
delete [] errorsignal_hidden;
delete [] errorsignal_output;
file_loaded = ;
return;
}
初始化的神经网络的数据文件:
0.5 5.747781 -6.045236 1.206744 -41.245163 -0.249886 -0.35452 0.0718 -8.446443 9.25553 -6.50087 7.357942 7.777944 1.238442 15.957281 0.452741 -8.19198 9.140881 29.124746 9.806898 5.859479 -5.09182 -3.475694 -4.896269 6.320669 0.213897 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!explanation of datafile. Can be deleted. Not necessary for network to work!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (number of input units)
(number of hidden units)
(number of output units)
0.5 (learning rate)
(number of input and target output patterns) (has to correspond to the amount of patterns at the end of the datafile)
5.747781 -6.045236 1.206744 -41.245163 -0.249886 -0.35452 0.0718 (biases of hidden and output units, first three are biases of the hidden units, last four are biases of the output units) -8.446443 9.25553 -6.50087 7.357942 7.777944 1.238442 (values of weights from input to hidden units) 15.957281 0.452741 -8.19198 9.140881 29.124746 9.806898 5.859479 -5.09182 -3.475694 -4.896269 6.320669 0.213897 (values of weights from hidden to output units) (input pattern #)
(input pattern #)
(input pattern #)
(input pattern #) (target output pattern #)
(target output pattern #)
(target output pattern #)
(target output pattern #) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! end of explanation of datafile. !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
按照数据输入说明,可以再b.txt文件中保存输入数据[0, 1],对应的输入结果如下:
可以看到,输入[0,1]得到的结果为0110,与训练时候的结果一直。
最后,本代码没有深入测试过,同时也只有一个隐层,所以建议只用来配合梳理算法原理用。
deep learning(1)BP神经网络原理与练习的更多相关文章
- 机器学习(4):BP神经网络原理及其python实现
BP神经网络是深度学习的重要基础,它是深度学习的重要前行算法之一,因此理解BP神经网络原理以及实现技巧非常有必要.接下来,我们对原理和实现展开讨论. 1.原理 有空再慢慢补上,请先参考老外一篇不错的 ...
- Deep Learning In NLP 神经网络与词向量
0. 词向量是什么 自然语言理解的问题要转化为机器学习的问题,第一步肯定是要找一种方法把这些符号数学化. NLP 中最直观,也是到目前为止最常用的词表示方法是 One-hot Representati ...
- BP神经网络原理及python实现
[废话外传]:终于要讲神经网络了,这个让我踏进机器学习大门,让我读研,改变我人生命运的四个字!话说那么一天,我在乱点百度,看到了这样的内容: 看到这么高大上,这么牛逼的定义,怎么能不让我这个技术宅男心 ...
- 机器学习入门学习笔记:(一)BP神经网络原理推导及程序实现
机器学习中,神经网络算法可以说是当下使用的最广泛的算法.神经网络的结构模仿自生物神经网络,生物神经网络中的每个神经元与其他神经元相连,当它“兴奋”时,想下一级相连的神经元发送化学物质,改变这些神经元的 ...
- BP神经网络原理详解
转自博客园@编程De: http://www.cnblogs.com/jzhlin/archive/2012/07/28/bp.html http://blog.sina.com.cn/s/blog ...
- BP神经网络原理及在Matlab中的应用
一.人工神经网络 关于对神经网络的介绍和应用,请看如下文章 神经网络潜讲 如何简单形象又有趣地讲解神经网络是什么 二.人工神经网络分类 按照连接方式--前向神经网络.反馈(递归)神经网络 按照 ...
- Deep Learning - 3 改进神经网络的学习方式
反向传播算法是大多数神经网络的基础,我们应该多花点时间掌握它. 还有一些技术能够帮助我们改进反向传播算法,从而改进神经网络的学习方式,包括: 选取更好的代价函数 正则化方法 初始化权重的方法 如何选择 ...
- bp神经网络原理
bp(back propagation)修改每层神经网络向下一层传播的权值,来减少输出层的实际值和理论值的误差 其实就是训练权值嘛 训练方法为梯度下降法 其实就是高等数学中的梯度,将所有的权值看成自变 ...
- Coursera Deep Learning笔记 卷积神经网络基础
参考1 参考2 1. 计算机视觉 使用传统神经网络处理机器视觉的一个主要问题是输入层维度很大.例如一张64x64x3的图片,神经网络输入层的维度为12288. 如果图片尺寸较大,例如一张1000x10 ...
随机推荐
- django 的请求处理部分----WSGIHandler 源码分析 django1.5.5
从这里拉开django框架的帷幕..撕开,哈哈 主要涉及的类:django.core.handlers.base.BaseHandler,django.core.handlers.wsgi.WSGIH ...
- Boost format
浅尝boost之format 概述 std::string是个很不错的东东,但实际使用时基本在每个程序里都会遇到不愉快的事情:格式化字符串.我甚至由于这个原因在代码里引入平台有关的MFC,A ...
- 常用后台frame框架
一般后台框架结构: top:左边显示logo,右边显示模块信息. left:对应模块的菜单信息. content:具体的内容. bottom:版权.时间等一些碎屑信息. Html代码: <htm ...
- Unity3d Shader开发(三)Pass(Blending )
混合被用于制作透明物体. 当图像被渲染时,所有着色器被执行以后,所有贴图被应用后,像素将被写到屏幕.他们是如何通过Blend命令的控制和已有的图像合并呢? Syntax 语法 Blend Off Tu ...
- BZOJ 2818GCD
Description 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. Input 一个整数N Output 如题 Sample Input 4 Sam ...
- javascript高级编程笔记02(基本概念)
ParseInt()函数: 由于Number函数在转换字符串时比较复杂而且不合理,我们常常转换字符串都用parseInt函数, Parseint函数规则: 忽略字符串前面的空格,直到找到第一个非空格字 ...
- js事件之神奇的onclick
21:58 2013/7/1 <a href="#" onclick="alert(123124);" >链接</a> 意思是鼠标点击链 ...
- C#基础|初探反射
什么是反射 我们编写的C#代码都可以编译成exe文件或dll文件.暂时先把他们叫做程序集吧,程序集中包含了很多信息.你写了一个类,类中会有字段,有属性,有方法,编译是会把这些信息保存在程序集中,暂时把 ...
- JS数据类型&&typeof&&其他
1. 5种基本数据类型: 1. String 2. Number 3. Boolean 4. Undefined 5. Null 2. 1种复杂数据类型:Object 3. 检测变量的数据类型:typ ...
- SQL server数据类型int、bigint、smallint、tinyint
1. 整数类型 int.bigint.smallint.tinyint 数据类型 范围 存储 bigint -2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9 ...