91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 16.42MB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發布日期: 2023-08-06
  • 語言: C/C++
  • 標簽:

資源簡介

機器學習經典算法的C語言代碼,比如:ID3算法 人臉識別源代碼 K緊鄰算法、人工神經網絡

資源截圖

代碼片段和文件信息

/*
?******************************************************************
?*?HISTORY
?*?15-Oct-94??Jeff?Shufelt?(js)?Carnegie?Mellon?University
?* Prepared?for?15-681?Fall?1994.
?*
?******************************************************************
?*/

#include?
#include?
#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?}

/***?Return?random?number?between?0.0?and?1.0?***/
double?drnd()
{
??return?((double)?random()?/?(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(x)
double?x;
{
??return?(1.0?/?(1.0?+?exp(-x)));
}


/***?Allocate?1d?array?of?doubles?***/

double?*alloc_1d_dbl(n)
int?n;
{
??double?*new;

??new?=?(double?*)?malloc?((unsigned)?(n?*?sizeof?(double)));
??if?(new?==?NULL)?{
????printf(“ALLOC_1D_DBL:?Couldn‘t?allocate?array?of?doubles\n“);
????return?(NULL);
??}
??return?(new);
}


/***?Allocate?2d?array?of?doubles?***/

double?**alloc_2d_dbl(m?n)
int?m?n;
{
??int?i;
??double?**new;

??new?=?(double?**)?malloc?((unsigned)?(m?*?sizeof?(double?*)));
??if?(new?==?NULL)?{
????printf(“ALLOC_2D_DBL:?Couldn‘t?allocate?array?of?dbl?ptrs\n“);
????return?(NULL);
??}

??for?(i?=?0;?i?????new[i]?=?alloc_1d_dbl(n);
??}

??return?(new);
}


bpnn_randomize_weights(w?m?n)
double?**w;
int?m?n;
{
??int?i?j;

??for?(i?=?0;?i?<=?m;?i++)?{
????for?(j?=?0;?j?<=?n;?j++)?{
??????w[i][j]?=?dpn1();
????}
??}
}


bpnn_zero_weights(w?m?n)
double?**w;
int?m?n;
{
??int?i?j;

??for?(i?=?0;?i?<=?m;?i++)?{
????for?(j?=?0;?j?<=?n;?j++)?{
??????w[i][j]?=?0.0;
????}
??}
}


void?bpnn_initialize(seed)
{
??printf(“Random?number?generator?seed:?%d\n“?seed);
??srandom(seed);
}


BPNN?*bpnn_internal_create(n_in?n_hidden?n_out)
int?n_in?n_hidden?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_p

評論

共有 條評論

相關資源