Pruning in Keras

不羁的心 提交于 2019-12-18 18:53:38

问题


I'm trying to design a neural network using Keras with priority on prediction performance, and I cannot get sufficiently high accuracy by further reducing the number of layers and nodes per layer. I have noticed that very large portion of my weights are effectively zero (>95%). Is there a way to prune dense layers in hope of reducing prediction time?


回答1:


Not a dedicated way :(

There's currently no easy (dedicated) way of doing this with Keras.

A discussion is ongoing at https://groups.google.com/forum/#!topic/keras-users/oEecCWayJrM.

You may also be interested in this paper: https://arxiv.org/pdf/1608.04493v1.pdf.




回答2:


Take a look at Keras Surgeon: https://github.com/BenWhetton/keras-surgeon

I have not tried it myself, but the documentation claims that it has functions to remove or insert nodes.

Also, after looking at some papers on pruning, it seems that many researchers create a new model with less channels (or less layers), and then copy the weights from the original model to the new model.




回答3:


See this dedicated tooling for Keras. https://www.tensorflow.org/model_optimization/guide/pruning

As the overview suggests, support for latency improvements is a work in progress




回答4:


If you set an individual weight to zero won't that prevent it from being updated during back propagation? Shouldn't thatv weight remain zero from one epoch to the next? That's why you set the initial weights to nonzero values before training. If you want to "remove" an entire node, just set all of the weights on that node's output to zero and that will prevent that nodes from having any affect on the output throughout training.



来源:https://stackoverflow.com/questions/41958566/pruning-in-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!