{"action":"created","issue":{"url":"https://api.github.com/repos/wenwei202/caffe/issues/22","repository_url":"https://api.github.com/repos/wenwei202/caffe","labels_url":"https://api.github.com/repos/wenwei202/caffe/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/wenwei202/caffe/issues/22/comments","events_url":"https://api.github.com/repos/wenwei202/caffe/issues/22/events","html_url":"https://github.com/wenwei202/caffe/issues/22","id":304228333,"number":22,"title":"hi, what 'convq_layer' means in net_pruner.py and net_skipper.py?","user":{"login":"zhujiacheng","id":13119887,"avatar_url":"https://avatars2.githubusercontent.com/u/13119887?v=4","gravatar_id":"","url":"https://api.github.com/users/zhujiacheng","html_url":"https://github.com/zhujiacheng","followers_url":"https://api.github.com/users/zhujiacheng/followers","following_url":"https://api.github.com/users/zhujiacheng/following{/other_user}","gists_url":"https://api.github.com/users/zhujiacheng/gists{/gist_id}","starred_url":"https://api.github.com/users/zhujiacheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhujiacheng/subscriptions","organizations_url":"https://api.github.com/users/zhujiacheng/orgs","repos_url":"https://api.github.com/users/zhujiacheng/repos","events_url":"https://api.github.com/users/zhujiacheng/events{/privacy}","received_events_url":"https://api.github.com/users/zhujiacheng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-12T03:11:46Z","updated_at":"2018-03-13T07:55:20Z","closed_at":null,"author_association":"NONE","body":"hi,  \r\n    In my opinion there should be some python scripts that can remove all-ZEROs-weights filters(row sparsity) directly to accelerate GPU inferences without any CPU subroutines, so are the net_pruner.py and net_skipper.py  used for that?  Or Can you give me some advises?\r\n    and I can not figure out  what 'convq_layer' and 'convq_param_key' means in net_pruner.py and net_skipper.py, for example there obvioursly do not exit 'conv1q' key in src_net.params. \r\n    Thanks a lot for your help! \r\n`\r\n\r\n    src_net = caffe.Net(srcproto,srcmodel, caffe.TEST)\r\n    print(\"src net:\\n blobs {}\\nparams {}\\n\".format(src_net.blobs.keys(), src_net.params.keys()))\r\n    src_net_parser = caffeparser.CaffeProtoParser(srcproto)\r\n    net_msg = src_net_parser.readProtoNetFile()\r\n\r\n    layer_idx = 0\r\n    loop_layers = net_msg.layer[:] #adding : implicitly makes a copy to avoid being modified in the loop\r\n    convxq_positions = []\r\n    convxq_m = []\r\n    convxq_add_layers = []\r\n    position_idx = 0\r\n\r\n    total_all_zero_counter = 0\r\n\r\n    # generate and save dst prototxt\r\n\r\n    for cur_layer in loop_layers:\r\n        if 'Convolution'==cur_layer.type and re.match(\"^conv[0-9]+$\",cur_layer.name):\r\n            convq_layer = net_msg.layer._values[position_idx-1]\r\n            convq_param_key = cur_layer.name+\"q\"\r\n            param_key = cur_layer.name\r\n            convx_ptr = net_msg.layer._values.pop(position_idx)\r\n            convx_ptr.CopyFrom(cur_layer)\r\n            convxq_ptr = net_msg.layer._values.pop(position_idx-1)\r\n            convxq_ptr.CopyFrom(convq_layer)\r\n\r\n            assert len(src_net.params[convq_param_key])==1\r\n            weights_convxq = src_net.params[convq_param_key][0].data\r\n            weights_convx = src_net.params[param_key][0].data\r\n            assert weights_convx.shape[3]==1 and weights_convx.shape[2]==1\r\n\r\n            orig_grp_num = weights_convxq.shape[0]/weights_convx.shape[1]\r\n            cur_m = convq_layer.convolution_param.group\r\n            orig_grp_num = cur_layer.convolution_param.group\r\n            num_per_orig_grp = (cur_m/orig_grp_num)\r\n            cur_sxs = weights_convx.shape[1]*orig_grp_num/cur_m\r\n`"},"comment":{"url":"https://api.github.com/repos/wenwei202/caffe/issues/comments/372577177","html_url":"https://github.com/wenwei202/caffe/issues/22#issuecomment-372577177","issue_url":"https://api.github.com/repos/wenwei202/caffe/issues/22","id":372577177,"user":{"login":"zhujiacheng","id":13119887,"avatar_url":"https://avatars2.githubusercontent.com/u/13119887?v=4","gravatar_id":"","url":"https://api.github.com/users/zhujiacheng","html_url":"https://github.com/zhujiacheng","followers_url":"https://api.github.com/users/zhujiacheng/followers","following_url":"https://api.github.com/users/zhujiacheng/following{/other_user}","gists_url":"https://api.github.com/users/zhujiacheng/gists{/gist_id}","starred_url":"https://api.github.com/users/zhujiacheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhujiacheng/subscriptions","organizations_url":"https://api.github.com/users/zhujiacheng/orgs","repos_url":"https://api.github.com/users/zhujiacheng/repos","events_url":"https://api.github.com/users/zhujiacheng/events{/privacy}","received_events_url":"https://api.github.com/users/zhujiacheng/received_events","type":"User","site_admin":false},"created_at":"2018-03-13T07:55:20Z","updated_at":"2018-03-13T07:55:20Z","author_association":"NONE","body":"@wenwei202 thanks for your help.\r\nbut when I test the inference time with examples/cifar10_classifier.py  on one nivdia 1070 gpu, the model's sparsity and the result following.\r\n### cifar10_full_ssl_200000.caffemodel sparsity\r\n`\r\nI0313 15:25:18.214439  3057 base_conv_layer.cpp:17] layer\tconv1\thas sparsity of 0.610833\r\nI0313 15:25:18.215625  3057 base_conv_layer.cpp:61] ConvolutionParameter_ConvMode_LOWERED_CCNMM\r\nI0313 15:25:18.215688  3057 base_conv_layer.cpp:80] concatenating weight matrix\r\nI0313 15:25:18.215701  3057 base_conv_layer.cpp:88] conv1 left_cols=75 left_rows=14\r\nI0313 15:25:18.215739  3057 base_conv_layer.cpp:91] squeezing weight matrix\r\nI0313 15:25:18.215749  3057 base_conv_layer.cpp:102] conv1 squeezing to 14x75\r\nI0313 15:25:18.215775  3057 base_conv_layer.cpp:114] weight matrix squeezed\r\nI0313 15:25:18.215785  3057 base_conv_layer.cpp:180] weights lying in all-zero groups of conv1 are frozen\r\nI0313 15:25:18.216166  3057 base_conv_layer.cpp:17] layer\tconv2\thas sparsity of 0.848477\r\nI0313 15:25:18.226200  3057 base_conv_layer.cpp:61] ConvolutionParameter_ConvMode_LOWERED_CCNMM\r\nI0313 15:25:18.226290  3057 base_conv_layer.cpp:80] concatenating weight matrix\r\nI0313 15:25:18.226305  3057 base_conv_layer.cpp:88] conv2 left_cols=270 left_rows=20\r\nI0313 15:25:18.226348  3057 base_conv_layer.cpp:91] squeezing weight matrix\r\nI0313 15:25:18.226358  3057 base_conv_layer.cpp:102] conv2 squeezing to 20x270\r\nI0313 15:25:18.226404  3057 base_conv_layer.cpp:114] weight matrix squeezed\r\nI0313 15:25:18.226415  3057 base_conv_layer.cpp:180] weights lying in all-zero groups of conv2 are frozen\r\nI0313 15:25:18.227262  3057 base_conv_layer.cpp:17] layer\tconv3\thas sparsity of 0.660352\r\nI0313 15:25:18.249153  3057 base_conv_layer.cpp:61] ConvolutionParameter_ConvMode_LOWERED_CCNMM\r\nI0313 15:25:18.249279  3057 base_conv_layer.cpp:80] concatenating weight matrix\r\nI0313 15:25:18.249299  3057 base_conv_layer.cpp:88] conv3 left_cols=486 left_rows=62\r\nI0313 15:25:18.249359  3057 base_conv_layer.cpp:91] squeezing weight matrix\r\nI0313 15:25:18.249370  3057 base_conv_layer.cpp:102] conv3 squeezing to 62x486\r\nI0313 15:25:18.249470  3057 base_conv_layer.cpp:114] weight matrix squeezed\r\nI0313 15:25:18.249481  3057 base_conv_layer.cpp:180] weights lying in all-zero groups of conv3 are frozen\r\nI0313 15:25:18.249981  3057 inner_product_layer.cpp:12] layer\tip1\thas sparsity of 0.153613\r\nI0313 15:25:18.254674  3057 inner_product_layer.cpp:20] weights lying in all-zero groups of ip1 are frozen\r\nI0313 15:25:18.254782  3057 net.cpp:895] Ignoring source layer loss\r\n`\r\n###  inference times (batch_size=32)\r\n\r\n  | cifar10_full.prototxt | cifar10_full_ccnmm.prototxt  conv_mode: LOWERED_CCNMM\r\n-- | -- | --\r\ncifar10_full_baseline.caffemodel | 5ms(Top 1): 81.52%  (Top 5): 99.04% | 31ms   (Top 1): 81.52%  (Top 5): 99.05%\r\ncifar10_full_ssl_200000.caffemodel | 5ms(Top 1): 80.37%  (Top 5): 98.90% | 31ms   (Top 1): 80.37%  (Top 5): 98.90%\r\n\r\n### Why?\r\nso  Why the inference time is much more when conv_mode: LOWERED_CCNMM, and I can not see the inference time cuts down when using cifar10_full_ssl_200000.caffemodel?"}}
{"actor":{"display_login":"zhujiacheng"}}