资源简介
卷积神经网络lenet-5的实现代码 c++版本
代码片段和文件信息
/*
Copyright (c) 2013 Taiga Nomi
All rights reserved.
Redistribution and use in source and binary forms with or without
modification are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS“ AND ANY
EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES
(INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include
#include
#include
#include “tiny_cnn.h“
//#define NOMINMAX
//#include “imdebug.h“
void sample1_3layerNN();
using namespace tiny_cnn;
int main(void) {
// construct LeNet-5 architecture
typedef network CNN;
CNN nn;
convolutional_layer C1(32 32 5 1 6);
average_pooling_layer S2(28 28 6 2);
// connection table [Y.Lecun 1998 Table.1]
#define O true
#define X false
static const bool connection[] = {
O X X X O O O X X O O O O X O O
O O X X X O O O X X O O O O X O
O O O X X X O O O X X O X O O O
X O O O X X O O O O X X O X O O
X X O O O X X O O O O X O O X O
X X X O O O X X O O O O X O O O
};
#undef O
#undef X
convolutional_layer C3(14 14 5 6 16 connection_table(connection 6 16));
average_pooling_layer S4(10 10 16 2);
convolutional_layer C5(5 5 5 16 120);
fully_connected_layer F6(120 10);
assert(C1.param_size() == 156 && C1.connection_size() == 122304);
assert(S2.param_size() == 12 && S2.connection_size() == 5880);
assert(C3.param_size() == 1516 && C
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 483 2014-02-11 06:00 cnn_vs2012\.gitattributes
....... 2107 2014-02-11 06:00 cnn_vs2012\.gitignore
....... 2053 2014-02-11 06:00 cnn_vs2012\README.md
....... 3628 2014-02-11 06:00 cnn_vs2012\include\activation_function.h
....... 3501 2014-02-11 06:00 cnn_vs2012\include\average_pooling_la
....... 1920 2014-02-11 06:00 cnn_vs2012\include\config.h
....... 6262 2014-02-11 06:00 cnn_vs2012\include\convolutional_la
....... 1966 2014-02-11 06:00 cnn_vs2012\include\deform.h
....... 5793 2014-02-11 06:00 cnn_vs2012\include\fixed_point.h
....... 5041 2014-02-11 06:00 cnn_vs2012\include\fully_connected_la
....... 4636 2014-02-11 06:00 cnn_vs2012\include\image.h
....... 10225 2014-02-11 06:00 cnn_vs2012\include\la
....... 2097 2014-02-11 06:00 cnn_vs2012\include\loss_function.h
....... 4612 2014-02-11 06:00 cnn_vs2012\include\mnist_parser.h
....... 13429 2014-02-11 06:00 cnn_vs2012\include\network.h
....... 2731 2014-02-11 06:00 cnn_vs2012\include\optimizer.h
....... 8703 2014-02-11 06:00 cnn_vs2012\include\partial_connected_la
....... 23363 2014-02-11 06:00 cnn_vs2012\include\picotest.h
....... 12527 2014-02-11 06:00 cnn_vs2012\include\product.h
....... 1910 2014-02-11 06:00 cnn_vs2012\include\tiny_cnn.h
....... 5446 2014-02-11 06:00 cnn_vs2012\include\util.h
....... 6757 2014-02-11 06:00 cnn_vs2012\src\main.cpp
....... 15168 2014-02-11 06:00 cnn_vs2012\src\test.cpp
....... 352 2014-02-11 06:00 cnn_vs2012\src\wsc
....... 2039 2014-02-11 06:00 cnn_vs2012\vc\cnn.vcxproj.filters
....... 7840016 2014-02-11 06:00 cnn_vs2012\vc\t10k-images.idx3-ubyte
....... 10008 2014-02-11 06:00 cnn_vs2012\vc\t10k-labels.idx1-ubyte
....... 1936 2014-02-11 06:00 cnn_vs2012\vc\test.vcxproj.filters
....... 1320 2014-02-11 06:00 cnn_vs2012\vc\tiny_cnn.sln
....... 5856 2014-02-11 06:00 cnn_vs2012\vc\tiny_cnn.vcxproj
............此处省略12个文件信息
评论
共有 条评论