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

資源簡介

LeNet-5神經(jīng)網(wǎng)絡(luò) C源代碼,這個寫的比較好,可以用gcc編譯去跑,結(jié)合理論可以對深度學(xué)習(xí)有更深刻的了解 介紹 根據(jù)YANN LECUN的論文《Gradient-based Learning Applied To Document Recognition》設(shè)計(jì)的LeNet-5神經(jīng)網(wǎng)絡(luò),C語言寫成,不依賴任何第三方庫。 MNIST手寫字符集初代訓(xùn)練識別率97%,多代訓(xùn)練識別率98%。 DEMO main.c文件為MNIST數(shù)據(jù)集的識別DEMO,直接編譯即可運(yùn)行,訓(xùn)練集60000張,測試集10000張。 項(xiàng)目環(huán)境 該項(xiàng)目為VISUAL STUDIO 2015項(xiàng)目,用VISUAL STUDIO 2015 UPDATE1及以上直接打開即可編譯。采用ANSI C編寫,因此源碼無須修改即可在其它平臺上編譯。 如果因缺少openmp無法編譯,請將lenet.c中的#include和#pragma omp parallel for刪除掉即可。 API #####批量訓(xùn)練 lenet: LeNet5的權(quán)值的指針,LeNet5神經(jīng)網(wǎng)絡(luò)的核心 inputs: 要訓(xùn)練的多個圖片對應(yīng)unsigned char二維數(shù)組的數(shù)組,指向的二維數(shù)組的batchSize倍大小內(nèi)存空間指針。在MNIST測試DEMO中二維數(shù)組為28x28,每個二維數(shù)組數(shù)值分別為對應(yīng)位置圖像像素灰度值 resMat:結(jié)果向量矩陣 labels:要訓(xùn)練的多個圖片分別對應(yīng)的標(biāo)簽數(shù)組。大小為batchSize batchSize:批量訓(xùn)練輸入圖像(二維數(shù)組)的數(shù)量 void TrainBatch(LeNet5 *lenet, image *inputs, const char(*resMat)[OUTPUT],uint8 *labels, int batchSize); #####單個訓(xùn)練 lenet: LeNet5的權(quán)值的指針,LeNet5神經(jīng)網(wǎng)絡(luò)的核心 input: 要訓(xùn)練的圖片對應(yīng)二維數(shù)組 resMat:結(jié)果向量矩陣 label: 要訓(xùn)練的圖片對應(yīng)的標(biāo)簽 void Train(LeNet5 *lenet, image input, const char(*resMat)[OUTPUT],uint8 label); #####預(yù)測 lenet: LeNet5的權(quán)值的指針,LeNet5神經(jīng)網(wǎng)絡(luò)的核心 input: 輸入的圖像的數(shù)據(jù) labels: 結(jié)果向量矩陣指針 count: 結(jié)果向量個數(shù) return 返回值為預(yù)測的結(jié)果 int Predict(LeNet5 *lenet, image input, const char(*labels)[LAYER6], int count); #####初始化 lenet: LeNet5的權(quán)值的指針,LeNet5神經(jīng)網(wǎng)絡(luò)的核心

資源截圖

代碼片段和文件信息

#include?“l(fā)enet.h“
#include?
#include?
#include?
#include?

#define?GETLENGTH(array)?(sizeof(array)/sizeof(*(array)))

#define?GETCOUNT(array)??(sizeof(array)/sizeof(double))

#define?FOREACH(icount)?for?(int?i?=?0;?i?
#define?CONVOLUTE_VALID(inputoutputweight) \
{ \
FOREACH(o0GETLENGTH(output)) \
FOREACH(o1GETLENGTH(*(output))) \
FOREACH(w0GETLENGTH(weight)) \
FOREACH(w1GETLENGTH(*(weight))) \
(output)[o0][o1]?+=?(input)[o0?+?w0][o1?+?w1]?*?(weight)[w0][w1]; \
}

#define?CONVOLUTE_FULL(inputoutputweight) \
{ \
FOREACH(i0GETLENGTH(input)) \
FOREACH(i1GETLENGTH(*(input))) \
FOREACH(w0GETLENGTH(weight)) \
FOREACH(w1GETLENGTH(*(weight))) \
(output)[i0?+?w0][i1?+?w1]?+=?(input)[i0][i1]?*?(weight)[w0][w1]; \
}

#define?CONVOLUTION_FORWARD(inputoutputweightbiasaction) \
{ \
for?(int?x?=?0;?x? for?(int?y?=?0;?y? CONVOLUTE_VALID(input[x]?output[y]?weight[x][y]); \
FOREACH(j?GETLENGTH(output)) \
FOREACH(i?GETCOUNT(output[j])) \
((double?*)output[j])[i]?=?action(((double?*)output[j])[i]?+?bias[j]); \
}

#define?CONVOLUTION_BACKWARD(inputinerrorouterrorweightwdbdactiongrad)\
{ \
for?(int?x?=?0;?x? for?(int?y?=?0;?y? CONVOLUTE_FULL(outerror[y]?inerror[x]?weight[x][y]); \
FOREACH(i?GETCOUNT(inerror)) \
((double?*)inerror)[i]?*=?actiongrad(((double?*)input)[i]); \
FOREACH(j?GETLENGTH(outerror)) \
FOREACH(i?GETCOUNT(outerror[j])) \
bd[j]?+=?((double?*)outerror[j])[i]; \
for?(int?x?=?0;?x? for?(int?y?=?0;?y? CONVOLUTE_VALID(input[x]?wd[x][y]?outerror[y]); \
}


#define?SUBSAMP_MAX_FORWARD(inputoutput) \
{ \
const?int?len0?=?GETLENGTH(*(input))?/?GETLENGTH(*(output)); \
const?int?len1?=?GETLENGTH(**(input))?/?GETLENGTH(**(output)); \
FOREACH(i?GETLENGTH(output)) \
FOREACH(o0?GETLENGTH(*(output))) \
FOREACH(o1?GETLENGTH(**(output))) \
{ \
int?x0?=?0?x1?=?0?ismax; \
FOREACH(l0?len0) \
FOREACH(l1?len1) \
{ \
ismax?=?input[i][o0*len0?+?l0][o1*len1?+?l1]?>?input[i][o0*len0?+?x0][o1*len1?+?x1];\
x0?+=?ismax?*?(l0?-?x0); \
x1?+=?ismax?*?(l1?-?x1); \
} \
output[i][o0][o1]?=?input[i][o0*len0?+?x0][o1*len1?+?x1]; \
} \
}

#define?SUBSAMP_MAX_BACKWARD(inputinerrorouterror)

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\
?????文件????????2518??2017-01-01?04:35??LeNet-5-master\.gitattributes
?????文件????????3461??2017-01-01?04:35??LeNet-5-master\.gitignore
?????文件????????1078??2017-01-01?04:35??LeNet-5-master\LICENSE
?????文件????????1275??2017-01-01?04:35??LeNet-5-master\LeNet-5.sln
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\
?????文件????????8202??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.pbxproj
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.xcworkspace\
?????文件?????????152??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.xcworkspace\contents.xcworkspacedata
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.xcworkspace\xcuserdata\
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.xcworkspace\xcuserdata\fanwenjie.xcuserdatad\
?????文件???????35009??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\project.xcworkspace\xcuserdata\fanwenjie.xcuserdatad\UserInterfaceState.xcuserstate
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\xcuserdata\
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\xcuserdata\fanwenjie.xcuserdatad\
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\xcuserdata\fanwenjie.xcuserdatad\xcschemes\
?????文件????????3287??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\xcuserdata\fanwenjie.xcuserdatad\xcschemes\LeNet-5.xcscheme
?????文件?????????479??2017-01-01?04:35??LeNet-5-master\LeNet-5.xcodeproj\xcuserdata\fanwenjie.xcuserdatad\xcschemes\xcschememanagement.plist
?????目錄???????????0??2017-01-01?04:35??LeNet-5-master\LeNet-5\
?????文件????????7411??2017-01-01?04:35??LeNet-5-master\LeNet-5\LeNet-5.vcxproj
?????文件????????1543??2017-01-01?04:35??LeNet-5-master\LeNet-5\LeNet-5.vcxproj.filters
?????文件???????10348??2017-01-01?04:35??LeNet-5-master\LeNet-5\lenet.c
?????文件????????2115??2017-01-01?04:35??LeNet-5-master\LeNet-5\lenet.h
?????文件????????3285??2017-01-01?04:35??LeNet-5-master\LeNet-5\main.c
?????文件?????7840016??2017-01-01?04:35??LeNet-5-master\LeNet-5\t10k-images-idx3-ubyte
?????文件???????10008??2017-01-01?04:35??LeNet-5-master\LeNet-5\t10k-labels-idx1-ubyte
?????文件????47040016??2017-01-01?04:35??LeNet-5-master\LeNet-5\train-images-idx3-ubyte
?????文件???????60008??2017-01-01?04:35??LeNet-5-master\LeNet-5\train-labels-idx1-ubyte
?????文件????????2023??2017-01-01?04:35??LeNet-5-master\README.md

評論

共有 條評論

相關(guān)資源