farmingyard / caffe-mobilenet Goto Github PK
View Code? Open in Web Editor NEWA caffe implementation of mobilenet's depthwise convolution layer.
A caffe implementation of mobilenet's depthwise convolution layer.
Hi,
I am using the imagenet pre-trained model to finetune for classification.
If I use the DepthWiseconvolution layer, the loss first decreases and then starts to increase within 100 iterations.
However, with everything else as in the above fine tuning (i.e Base LR, solver etc), if i replace the ConvolutionDepthwise with Convolution layer the loss converges.
I tried fiddling with learning rates and solvers, but it didn't help.
I want to use the ConvolutionalDepthwise, as it is ~4 times faster than convolution.
Why the BN layer of your deploy.prototxt does not set "use_global_stats: true"
Thanks @farmingyard
what‘s the differences from the original convolutional layer with group ?
I do not understand how to implement relu6 operation that mentionde in paper,
and i do not found the ops in the the deploy.prototxt .can you tell me?
@farmingyard
Hi @farmingyard ,
I am new to caffe. I got an error saying like "class caffe::ConvolutionParameter’ has no member named ‘kernel_size_size’" in conv_dw_layer.cpp when I'm trying to compile.
Any idea of this error?
FYI, I put the hpp file in caffe_root/inclide/caffe and caffe_root/inclide/caffe/layers. The cu and cpp files in caffe_root/src/caffe/layers. I cannot define it in caffe.proto because there's already a ConvolutionParameter option existing.
thanks!
Hi, this is the error that i got,
*** Aborted at 1503583882 (unix time) try "date -d @1503583882" if you are using GNU date ***
PC: @ 0x7f786fd5cda6 caffe::ConvolutionDepthwiseLayer<>::LayerSetUp()
*** SIGSEGV (@0x0) received by PID 17642 (TID 0x7f7870a88740) from PID 0; stack trace: ***
@ 0x7f786e6834b0 (unknown)
@ 0x7f786fd5cda6 caffe::ConvolutionDepthwiseLayer<>::LayerSetUp()
@ 0x7f786ff0cba2 caffe::Net<>::Init()
@ 0x7f786ff0e431 caffe::Net<>::Net()
@ 0x7f786feb546a caffe::Solver<>::InitTrainNet()
@ 0x7f786feb67e7 caffe::Solver<>::Init()
@ 0x7f786feb6b8a caffe::Solver<>::Solver()
@ 0x7f786fd3db93 caffe::Creator_SGDSolver<>()
@ 0x40aa49 train()
@ 0x407350 main
@ 0x7f786e66e830 __libc_start_main
@ 0x407b79 _start
@ 0x0 (unknown)
Segmentation fault (core dumped)
Seems that caffe does not recognize this kernel, any clue ? I am using the a old and customized caffe, so i can not switch to the newest caffe easily
hi,
I'm modifying a network with mobilenet in caffe. At the time of training, an error occurred, as fellows:
.......
I1205 23:51:29.949239 21979 net.cpp:84] Creating Layer conv1_2/dw
I1205 23:51:29.949245 21979 net.cpp:406] conv1_2/dw <- conv1_1
I1205 23:51:29.949250 21979 net.cpp:380] conv1_2/dw -> conv1_2/dw
- Aborted at 1512489089 (unix time) try "date -d @1512489089" if you are using GNU date ***
PC: @ 0x7fce5eeb1ce6 caffe::ConvolutionDepthwiseLayer<>::LayerSetUp()
*** SIGSEGV (@0x0) received by PID 21979 (TID 0x7fce5fc019c0) from PID 0; stack trace: ***@ 0x7fce48883370 (unknown) @ 0x7fce5eeb1ce6 caffe::ConvolutionDepthwiseLayer<>::LayerSetUp() @ 0x7fce5eec3b1c caffe::Net<>::Init() @ 0x7fce5eec5772 caffe::Net<>::Net() @ 0x7fce5eed5008 caffe::Solver<>::InitTrainNet() @ 0x7fce5eed5f53 caffe::Solver<>::Init() @ 0x7fce5eed622f caffe::Solver<>::Solver() @ 0x7fce5eeecb11 caffe::Creator_SGDSolver<>() @ 0x41224e caffe::SolverRegistry<>::CreateSolver() @ 0x40a778 train() @ 0x40817c main @ 0x7fce484d4b35 __libc_start_main @ 0x408a61 (unknown)
the correspondence position in prototxt:
......
#conv1_2
layer {
name: "conv1_2/dw"
type: "ConvolutionDepthwise"
bottom: "conv1_1"
top: "conv1_2/dw"
param {
lr_mult: 1.0
decay_mult: 1
}
param {
lr_mult: 2.0
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
weight_filler {
type: "msra"
# std: 0.01
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
......
the .cpp/.cu files have been put in 'caffe/src/caffe/layers', and .hpp put in 'caffe/include/caffe/layers', I did not do other changes.
So, can you give me some comments about this error?
thank you!
@farmingyard
About 8GB for a 5.2M model, is that too weird?
I want to use mobilenet for Object detection,so i tried your caffe-implementation firstly。 i have add your files to the caffe (include、src), i dont konw whether should i modify the caffe.proto, for the new ConvolutionDepthwise ,could you help me?
@farmingyard Hello, I think "caffe_gpu_set" should be "caffe_set" in line 125 and 139 in conv_dw_layer.cpp
at the same time, "mutable_gpu_data" should "mutable_cpu_data"
caffe-mobilenet/conv_dw_layer.cpp
Line 125 in f7d7d13
I encountered this error when making caffe with conv_dw_layer added. And I tried to make caffe without gpu. Anyone have any ideas about this error? Thank you very much!
Hi @farmingyard ,
Have you trained with your prototxt and do you reach the paper acc?
I followed the resnext training policy yet have 1%~2% difference below the paper acc.
I'd be appreciated if there're any tricks to share.
thx!
I compile in only CPU mode,it is OK;but when I run "caffe time ...",error is :
Creating layer input
I0921 18:25:06.099230 50494 net.cpp:84] Creating Layer input
I0921 18:25:06.099251 50494 net.cpp:380] input -> data
I0921 18:25:06.099303 50494 net.cpp:122] Setting up input
I0921 18:25:06.099344 50494 net.cpp:129] Top shape: 1 3 224 224 (150528)
I0921 18:25:06.099360 50494 net.cpp:137] Memory required for data: 602112
I0921 18:25:06.099381 50494 layer_factory.hpp:77] Creating layer conv1
I0921 18:25:06.099452 50494 net.cpp:84] Creating Layer conv1
I0921 18:25:06.099472 50494 net.cpp:406] conv1 <- data
I0921 18:25:06.099494 50494 net.cpp:380] conv1 -> conv1
I0921 18:25:06.101721 50494 net.cpp:122] Setting up conv1
I0921 18:25:06.101753 50494 net.cpp:129] Top shape: 1 16 112 112 (200704)
I0921 18:25:06.101770 50494 net.cpp:137] Memory required for data: 1404928
I0921 18:25:06.101793 50494 layer_factory.hpp:77] Creating layer conv1/bn
I0921 18:25:06.101812 50494 net.cpp:84] Creating Layer conv1/bn
I0921 18:25:06.101830 50494 net.cpp:406] conv1/bn <- conv1
I0921 18:25:06.101845 50494 net.cpp:367] conv1/bn -> conv1 (in-place)
I0921 18:25:06.101891 50494 net.cpp:122] Setting up conv1/bn
I0921 18:25:06.101910 50494 net.cpp:129] Top shape: 1 16 112 112 (200704)
I0921 18:25:06.101924 50494 net.cpp:137] Memory required for data: 2207744
I0921 18:25:06.101945 50494 layer_factory.hpp:77] Creating layer conv1/scale
I0921 18:25:06.101970 50494 net.cpp:84] Creating Layer conv1/scale
I0921 18:25:06.101986 50494 net.cpp:406] conv1/scale <- conv1
I0921 18:25:06.102005 50494 net.cpp:367] conv1/scale -> conv1 (in-place)
I0921 18:25:06.102033 50494 layer_factory.hpp:77] Creating layer conv1/scale
I0921 18:25:06.102110 50494 net.cpp:122] Setting up conv1/scale
I0921 18:25:06.102131 50494 net.cpp:129] Top shape: 1 16 112 112 (200704)
I0921 18:25:06.102145 50494 net.cpp:137] Memory required for data: 3010560
I0921 18:25:06.102165 50494 layer_factory.hpp:77] Creating layer relu1
I0921 18:25:06.119302 50494 net.cpp:84] Creating Layer relu1
I0921 18:25:06.119323 50494 net.cpp:406] relu1 <- conv1
I0921 18:25:06.119333 50494 net.cpp:367] relu1 -> conv1 (in-place)
I0921 18:25:06.119351 50494 net.cpp:122] Setting up relu1
I0921 18:25:06.119360 50494 net.cpp:129] Top shape: 1 16 112 112 (200704)
I0921 18:25:06.119366 50494 net.cpp:137] Memory required for data: 3813376
I0921 18:25:06.119372 50494 layer_factory.hpp:77] Creating layer conv2_1/dw
I0921 18:25:06.119385 50494 net.cpp:84] Creating Layer conv2_1/dw
I0921 18:25:06.119390 50494 net.cpp:406] conv2_1/dw <- conv1
I0921 18:25:06.119398 50494 net.cpp:380] conv2_1/dw -> conv2_1/dw
F0921 18:25:06.119426 50494 syncedmem.cpp:150] Cannot use GPU in CPU-only Caffe: check mode.
*** Check failure stack trace: ***
@ 0x7f33d29cddaa (unknown)
@ 0x7f33d29cdce4 (unknown)
@ 0x7f33d29cd6e6 (unknown)
@ 0x7f33d29d0687 (unknown)
@ 0x7f33d2d7b625 caffe::SyncedMemory::mutable_gpu_data()
@ 0x7f33d2d7c762 caffe::Blob<>::mutable_gpu_data()
@ 0x7f33d2dc1202 caffe::ConvolutionDepthwiseLayer<>::Reshape()
@ 0x7f33d2ec26f5 caffe::Net<>::Init()
@ 0x7f33d2ec4e6b caffe::Net<>::Net()
@ 0x4086ec time()
@ 0x40594c main
@ 0x7f33d1224f45 (unknown)
@ 0x406253 (unknown)
@ (nil) (unknown)
Aborted (core dumped)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.