一个简单的卷积神经网络代码
A simple Convolutional neural network code
我对卷积神经网络 (CNN) 很感兴趣,它是计算广泛的应用示例,适用于使用可重构硬件(即 FPGA)进行加速
为了做到这一点,我需要检查一个简单的 CNN 代码,我可以用它来了解它们是如何实现的,每一层的计算是如何进行的,每一层的输出是如何被馈送到下一个的输入。我熟悉理论部分(http://cs231n.github.io/convolutional-networks/)
但是,我对训练 CNN 不感兴趣,我想要一个完整的、自包含的 CNN 代码,它是预训练的并且所有的权重和偏置值都是已知的。
我知道有很多 CNN 库,即 Caffe,但问题是没有独立的简单示例代码。即使对于最简单的 Caffe 示例 "cpp_classification" 也会调用许多库,CNN 的体系结构表示为 .prototxt 文件,还涉及其他类型的输入,例如 .caffemodel 和 .binaryproto。 openCV2 库也被调用。有一层又一层的抽象和不同的库一起工作以产生分类结果。
我知道生成 "useable" CNN 实现需要这些抽象,但对于需要学习基本代码的硬件人员来说,这太过分了 "un-related work"。
我的问题是:任何人都可以指导我开始一个简单且独立的 CNN 实现吗?
这是我见过的最简单的实现:DNN McCaffrey
此外,this by Karpathy 的源代码看起来非常简单。
我可以推荐tiny-cnn. It is simple, lightweight (e.g. header-only) and CPU only, while providing several layers frequently used within the literature (as for example pooling layers, dropout layers or local response normalization layer). This means, that you can easily explore an efficient implementation of these layers in C++ without requiring knowledge of CUDA and digging through the I/O and framework code as required by framework such as Caffe。实现缺少一些注释,但代码仍然易于阅读和理解。
提供MNIST example is quite easy to use (tried it myself some time ago) and trains efficiently. After training and testing, the weights are written to file. Then you have a simple pre-trained model from which you can start, see the provided examples/mnist/test.cpp and examples/mnist/train.cpp。它可以很容易地加载以进行测试(或识别数字),这样您就可以在执行学习模型的同时调试代码。
如果您想检查更复杂的网络,请查看 Cifar-10 Example。
我对卷积神经网络 (CNN) 很感兴趣,它是计算广泛的应用示例,适用于使用可重构硬件(即 FPGA)进行加速
为了做到这一点,我需要检查一个简单的 CNN 代码,我可以用它来了解它们是如何实现的,每一层的计算是如何进行的,每一层的输出是如何被馈送到下一个的输入。我熟悉理论部分(http://cs231n.github.io/convolutional-networks/)
但是,我对训练 CNN 不感兴趣,我想要一个完整的、自包含的 CNN 代码,它是预训练的并且所有的权重和偏置值都是已知的。
我知道有很多 CNN 库,即 Caffe,但问题是没有独立的简单示例代码。即使对于最简单的 Caffe 示例 "cpp_classification" 也会调用许多库,CNN 的体系结构表示为 .prototxt 文件,还涉及其他类型的输入,例如 .caffemodel 和 .binaryproto。 openCV2 库也被调用。有一层又一层的抽象和不同的库一起工作以产生分类结果。
我知道生成 "useable" CNN 实现需要这些抽象,但对于需要学习基本代码的硬件人员来说,这太过分了 "un-related work"。
我的问题是:任何人都可以指导我开始一个简单且独立的 CNN 实现吗?
这是我见过的最简单的实现:DNN McCaffrey
此外,this by Karpathy 的源代码看起来非常简单。
我可以推荐tiny-cnn. It is simple, lightweight (e.g. header-only) and CPU only, while providing several layers frequently used within the literature (as for example pooling layers, dropout layers or local response normalization layer). This means, that you can easily explore an efficient implementation of these layers in C++ without requiring knowledge of CUDA and digging through the I/O and framework code as required by framework such as Caffe。实现缺少一些注释,但代码仍然易于阅读和理解。
提供MNIST example is quite easy to use (tried it myself some time ago) and trains efficiently. After training and testing, the weights are written to file. Then you have a simple pre-trained model from which you can start, see the provided examples/mnist/test.cpp and examples/mnist/train.cpp。它可以很容易地加载以进行测试(或识别数字),这样您就可以在执行学习模型的同时调试代码。
如果您想检查更复杂的网络,请查看 Cifar-10 Example。