资源简介
使用c++开发的人工神经网络做人脸识别,内含数据集及测试集。
代码片段和文件信息
/*
******************************************************************
* HISTORY
* 15-Oct-94 Jeff Shufelt (js) Carnegie Mellon University
* Prepared for 15-681 Fall 1994.
*
******************************************************************
*/
#include “stdafx.h“
#include
#include “backprop.h“
#include
#define ABS(x) (((x) > 0.0) ? (x) : (-(x)))
#define fastcopy(tofromlen)\
{\
register char *_to*_from;\
register int _i_l;\
_to = (char *)(to);\
_from = (char *)(from);\
_l = (len);\
for (_i = 0; _i < _l; _i++) *_to++ = *_from++;\
}
/*** Return random number between 0.0 and 1.0 ***/
double drnd()
{
return ((double) rand() / (double) BIGRND);
}
/*** Return random number between -1.0 and 1.0 ***/
double dpn1()
{
return ((drnd() * 2.0) - 1.0);
}
/*** The squashing function. Currently it‘s a sigmoid. ***/
double squash(double x)
{
return (1.0 / (1.0 + exp(-x)));
}
/*** Allocate 1d array of doubles ***/
double *alloc_1d_dbl(int n)
{
double *newptr;
newptr = (double *) malloc ((unsigned) (n * sizeof (double)));
if (newptr == NULL) {
printf(“ALLOC_1D_DBL: Couldn‘t allocate array of doubles\n“);
return (NULL);
}
return (newptr);
}
/*** Allocate 2d array of doubles ***/
double **alloc_2d_dbl(int m int n)
{
int i;
double **newptr;
newptr = (double **) malloc ((unsigned) (m * sizeof (double *)));
if (newptr == NULL) {
printf(“ALLOC_2D_DBL: Couldn‘t allocate array of dbl ptrs\n“);
return (NULL);
}
for (i = 0; i < m; i++) {
newptr[i] = alloc_1d_dbl(n);
}
return (newptr);
}
void bpnn_randomize_weights(double **wint m int n)
{
int i j;
for (i = 0; i <= m; i++) {
for (j = 0; j <= n; j++) {
w[i][j] = dpn1();
}
}
}
void bpnn_zero_weights(double **wint m int n)
{
int i j;
for (i = 0; i <= m; i++) {
for (j = 0; j <= n; j++) {
w[i][j] = 0.0;
}
}
}
void bpnn_initialize(unsigned int seed)
{
printf(“Random number generator seed: %d\n“ seed);
srand(seed);
}
BPNN *bpnn_internal_create(int n_in int n_hidden int n_out)
{
BPNN *newnet;
newnet = (BPNN *) malloc (sizeof (BPNN));
if (newnet == NULL) {
printf(“BPNN_CREATE: Couldn‘t allocate neural network\n“);
return (NULL);
}
newnet->input_n = n_in;
newnet->hidden_n = n_hidden;
newnet->output_n = n_out;
newnet->input_units = alloc_1d_dbl(n_in + 1);
newnet->hidden_units = alloc_1d_dbl(n_hidden + 1);
newnet->output_units = alloc_1d_dbl(n_out + 1);
newnet->hidden_delta = alloc_1d_dbl(n_hidden + 1);
newnet->output_delta = alloc_1d_dbl(n_out + 1);
newnet->target = alloc_1d_dbl(n_out + 1);
newnet->input_weights = alloc_2d_dbl(n_in + 1 n_hidden + 1);
newnet->hidden_weights = alloc_2d_dbl(n_hidden + 1 n_out + 1);
newnet->input_prev_weights = alloc_2d_dbl(n_in + 1 n_hidden + 1);
newnet->hidden_prev_weights = alloc_2d_dbl(n_hidden + 1 n_out + 1);
return (newnet);
}
void bpnn_free(BPNN *net)
{
int n1
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 152 2004-11-14 15:37 demo.bat
目录 0 2006-11-07 01:52 faceimages\
目录 0 2006-11-07 01:52 faceimages\faces\
文件 131 1995-10-21 01:54 faceimages\faces\.anonr
目录 0 2006-11-07 01:52 faceimages\faces\an2i\
文件 42648 1995-10-07 03:41 faceimages\faces\an2i\an2i_left_angry_open.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_angry_open_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_angry_open_4.pgm
文件 42480 1995-10-07 03:44 faceimages\faces\an2i\an2i_left_angry_sunglasses.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_angry_sunglasses_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_angry_sunglasses_4.pgm
文件 42802 1995-10-07 03:39 faceimages\faces\an2i\an2i_left_happy_open.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_happy_open_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_happy_open_4.pgm
文件 42944 1995-10-07 03:42 faceimages\faces\an2i\an2i_left_happy_sunglasses.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_happy_sunglasses_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_happy_sunglasses_4.pgm
文件 43292 1995-10-07 03:38 faceimages\faces\an2i\an2i_left_neutral_open.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_neutral_open_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_neutral_open_4.pgm
文件 42974 1995-10-07 03:42 faceimages\faces\an2i\an2i_left_neutral_sunglasses.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_neutral_sunglasses_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_neutral_sunglasses_4.pgm
文件 42693 1995-10-07 03:40 faceimages\faces\an2i\an2i_left_sad_open.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_sad_open_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_sad_open_4.pgm
文件 42967 1995-10-07 03:43 faceimages\faces\an2i\an2i_left_sad_sunglasses.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_left_sad_sunglasses_2.pgm
文件 973 1995-10-08 05:54 faceimages\faces\an2i\an2i_left_sad_sunglasses_4.pgm
文件 42802 1995-10-07 03:41 faceimages\faces\an2i\an2i_right_angry_open.pgm
文件 3853 1995-10-19 12:07 faceimages\faces\an2i\an2i_right_angry_open_2.pgm
............此处省略1935个文件信息
相关资源
- c++ 多功能计算器
- C++17 In Detail
- 人脸识别(opencv_facedetect_v4l2)
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
- c++ 虚拟摄像头
- hook,捕获所有案件,查找所有窗口,
- C语言课设计算器
- c++ 简易贪吃蛇源码
- 高精度加法(c++代码)
- C++调用百度地图案例
- 北京化工大学计算方法(C/C++)讲义
- 基于VC++的SolidWorks二次开发SolidWorks
- c++ 模拟鼠标按键
- OFD编辑器
- Beginning C++17 From Novice to Professional
- C++ STL实现
- opencv手部轮廓识别以及轨迹识别
- 百度C++编码规范
- C++ sql2008 WebServer通讯.docx
- c++ 定时关机程序源码
- 基于VSCode和CMake实现C++开发
- c++语法查询工具
评论
共有 条评论