may0324 / deepcompression-caffe Goto Github PK
View Code? Open in Web Editor NEWCaffe for Deep Compression
License: Other
Caffe for Deep Compression
License: Other
您好:
我在编译的时候发现cpp文件中有masks_参数的运用,但是头文件中没有定义一系列参数,是在其他地方定义的吗?
/home4/jiashuaihe/environment/caffe/src/caffe/layers/cmp_conv_layer.cu(63): error: class "caffe::CmpConvolutionLayer" has no member "masks_"
detected during instantiation of "void caffe::CmpConvolutionLayer::Forward_gpu(const std::vector<caffe::Blob *, std::allocator<caffe::Blob *>> &, const std::vector<caffe::Blob *, std::allocator<caffe::Blob *>> &) [with Dtype=float]"
(132): here
*** Aborted at 1531205735 (unix time) try "date -d @1531205735" if you are using GNU date ***
PC: @ 0x7fae1722831b caffe::CmpConvolutionLayer<>::compute_output_shape()
*** SIGFPE (@0x7fae1722831b) received by PID 5626 (TID 0x7fae17e3e740) from PID 388137755; stack trace: ***
@ 0x7fae155754b0 (unknown)
@ 0x7fae1722831b caffe::CmpConvolutionLayer<>::compute_output_shape()
@ 0x7fae17123efc caffe::BaseConvolutionLayer<>::Reshape()
@ 0x7fae171ec2f2 caffe::CuDNNCmpConvolutionLayer<>::Reshape()
@ 0x7fae172882b8 caffe::Net<>::ForwardFromTo()
@ 0x7fae17288667 caffe::Net<>::Forward()
@ 0x7fae1726c4c0 caffe::Solver<>::Step()
@ 0x7fae1726cf59 caffe::Solver<>::Solve()
@ 0x40b408 train()
@ 0x4075a8 main
@ 0x7fae15560830 __libc_start_main
@ 0x407d19 _start
@ 0x0 (unknown)
Floating point exception (core dumped)
Anyone encountered this problem?
@liu666666 @A-suozhang
can you tell me the version of caffe? thx
Hi, @may0324
Thanks for your cool work!
After cloned this code, we have been trying to replicate Han's work in pruning conv-nets, especially the large one like caffenet, a variant of AlexNet.
In pruning fc6, the first fully connected layer in the network, we observed that, this layer can be pruned with the sparsity at most 0.4444444, that is, when you set the parameter sparse_ratio
to any number larger than 0.45, the actual sparsity is 0.4444444. This is rather weird to me.
Have you ever encountered this problem? Or could you please share your advice?
Thanks again!
Cheers!
作者你好,我看到全连接和卷积分别有带前缀cmp的实现。
mask_data
是该层被剪枝的权重在原矩阵中的位置嘛?muweight[i] = cent_data[indice_data[i]];
是否是对应的实现?template <typename Dtype>
void CmpInnerProductLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
Dtype* muweight = this->blobs_[0]->mutable_cpu_data();
const int *mask_data = this->masks_.cpu_data();
int count = this->blobs_[0]->count();
for (int i = 0; i < count; ++i)
muweight[i] *= mask_data[i] ;
if(this->quantize_term_)
{
const Dtype *cent_data = this->centroids_.cpu_data();
const int *indice_data = this->indices_.cpu_data();
for (int i = 0; i < count; ++i)
{
if (mask_data[i])
muweight[i] = cent_data[indice_data[i]];
}
}
const Dtype* bottom_data = bottom[0]->cpu_data();
Dtype* top_data = top[0]->mutable_cpu_data();
const Dtype* weight = this->blobs_[0]->cpu_data();
caffe_cpu_gemm<Dtype>(CblasNoTrans, transpose_ ? CblasNoTrans : CblasTrans,
M_, N_, K_, (Dtype)1.,
bottom_data, weight, (Dtype)0., top_data);
if (bias_term_) {
caffe_cpu_gemm<Dtype>(CblasNoTrans, CblasNoTrans, M_, N_, 1, (Dtype)1.,
bias_multiplier_.cpu_data(),
this->blobs_[1]->cpu_data(), (Dtype)1., top_data);
}
}
感谢~
Hi @may0324
Thanks for your awesome work. So far, I know the following
spare_ratio: 0 means disable pruning
quantize_term: false means disable quantization.
But I saw defalut value for class_num is 256. It seems weight sharing is always perform, right? Could we disable this?
If I am wrong, please correct me. Thanks :)
Some of the weights become very large when I run the gpu version. There may be some problems in "quantize_weight_backward".
您好, 感谢您的分享!@may0324
我想问您下 剪枝后的模型怎么存成size 小的caffemodel. 可以分享下有关这方面的代码吗,谢谢您!
Dear may0324:
At first, I must appreciate your time and effort on the tutorial. This is very excellent. Actually, I need some tools to prune VGG-16 for my research. Thus, may I ask a question ? Could the tool also work well on VGG-16? Will it be complex to implement pruning VGG-16? (Don't care the accuracy)
when snapshot start, it crash.
I0721 11:04:23.275313 17167 solver.cpp:244] Train net output #0: acc = 0.428571
I0721 11:04:23.275321 17167 solver.cpp:244] Train net output #1: loss = 1.88784 (* 1 = 1.88784 loss)
I0721 11:04:23.275328 17167 sgd_solver.cpp:106] Iteration 9, lr = 0.001
I0721 11:04:23.275475 17167 solver.cpp:454] Snapshotting to binary proto file dataset/lenet_iter_10.caffemodel```
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
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.