Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implement AlexNet with C / convolutional nerual network / machine learning / computer vision

License

NotificationsYou must be signed in to change notification settings

Dynmi/AlexNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Under Development

  • ! ! ! It needs an evaluation on ImageNet

This project is an unofficial implementation of AlexNet, using C Program Language Without Any 3rd Library, according to the paper "ImageNet Classification with Deep Convolutional Neural Networks" by Alex Krizhevsky,et al.

Only support CPU now

Features

  • Effective matrix multiply, w.r.t L1/L2 cache
  • img2col implementation of convolutional layer
  • Multi-thread CPU Apply MT in operator's forward computation and backward computation to boost speed
  • Efficient Memory Usage & Minimal Memory Occupation Memory is allocated on demand for efficient memory usage. If an array isn't necessary for computations afterward, it's memory will be freed instantly to minimize memory occupation.
  • Modular layer Define each layer seperately

Architecture

----------------------------------------------------------------            Layer                Output Shape         Param #================================================================            Conv2d-1           [N, 64, 55, 55]          23,296              ReLU-2           [N, 64, 55, 55]               0         MaxPool2d-3           [N, 64, 27, 27]               0            Conv2d-4          [N, 192, 27, 27]         307,392              ReLU-5          [N, 192, 27, 27]               0         MaxPool2d-6          [N, 192, 13, 13]               0            Conv2d-7          [N, 384, 13, 13]         663,936              ReLU-8          [N, 384, 13, 13]               0            Conv2d-9          [N, 256, 13, 13]         884,992             ReLU-10          [N, 256, 13, 13]               0           Conv2d-11          [N, 256, 13, 13]         590,080             ReLU-12          [N, 256, 13, 13]               0        MaxPool2d-13            [N, 256, 6, 6]               0          Dropout-14                 [N, 9216]               0           Linear-15                 [N, 4096]      37,752,832             ReLU-16                 [N, 4096]               0          Dropout-17                 [N, 4096]               0           Linear-18                 [N, 4096]      16,781,312             ReLU-19                 [N, 4096]               0           Linear-20                 [N, 1000]       4,097,000================================================================("N" stands for "batch size")Total params: 61,100,840Trainable params: 61,100,840Non-trainable params: 0----------------------------------------------------------------

Usage (Only for Linux now)

Install

git clone https://github.com/Dynmi/AlexNet.gitcd AlexNetmake clean && make all

Train

( The data loader only supports.jpeg and.png$ images now. For image dataset, go tohttp://www.image-net.org/)

  1. Create fileimages.list in the directory./, each line contains info of one image,like this:class_id image_path .

For example:

0 /home/haris/Documents/AlexNet/images/0/1.jpeg1 /home/haris/Documents/AlexNet/images/1/1.jpeg2 /home/haris/Documents/AlexNet/images/2/1.jpeg3 /home/haris/Documents/AlexNet/images/3/1.jpeg4 /home/haris/Documents/AlexNet/images/4/1.jpeg5 /home/haris/Documents/AlexNet/images/5/1.jpeg
  1. Run the command for training
./alexnet train -batchsize <batch-size> -epochs <epochs> -load_pretrained <weights-path> -save <weights-path>

For example:

./alexnet train -batchsize 8 -epochs 10 -load_pretrained ./alexnet_pretrained.weights -save ./temp.weights

Inference

$./alexnet inference -input <image-path> -load <weights-path>

For example:

./alexnet inference -input ./0001.jpeg -load ./alexnet_pretrained.weights

Todo List

  • Try & Compare on ImageNet

  • CUDA speed boosting

Speed Benchmark for Ops

Experiments were done on a laptop --- Huawei MagicBook14

Conv2D Forward

thisDarkNet
Scene10.13s0.44s
Scene20.21s0.66s

Scene1: Input shape [4,224,224,3], weight shape [64,3,11,11]

Scene2: Input shape [4,57,57,128], weight shape [256,128,3,3]

Full-connected Forward

thisDarkNet
Scene10.07s0.24s
Scene20.11s0.52s

Scene1: Input shape [4,2048], weight shape [2048,1024]

Scene2: Input shape [4,4096], weight shape [4096,4096]

Original AlexNet Details

divide the learning rate by 10 when the validation error rate stopped improving with the current learning rate.The learning rate was initialized at 0.01 and reduced three times prior to termination.We trained the network for roughly 90 cycles through the training set of 1.2 million images.

Reference

About

implement AlexNet with C / convolutional nerual network / machine learning / computer vision

Topics

Resources

License

Stars

Watchers

Forks

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp