{"action":"created","issue":{"url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/45","labels_url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/45/comments","events_url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/45/events","html_url":"https://github.com/sklearn-theano/sklearn-theano/issues/45","id":60270972,"number":45,"title":"ENH Decouple Protobuf requirement and extend sklearn_theano.feature_extraction.caffe","user":{"login":"erfannoury","id":1921165,"avatar_url":"https://avatars.githubusercontent.com/u/1921165?v=3","gravatar_id":"","url":"https://api.github.com/users/erfannoury","html_url":"https://github.com/erfannoury","followers_url":"https://api.github.com/users/erfannoury/followers","following_url":"https://api.github.com/users/erfannoury/following{/other_user}","gists_url":"https://api.github.com/users/erfannoury/gists{/gist_id}","starred_url":"https://api.github.com/users/erfannoury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erfannoury/subscriptions","organizations_url":"https://api.github.com/users/erfannoury/orgs","repos_url":"https://api.github.com/users/erfannoury/repos","events_url":"https://api.github.com/users/erfannoury/events{/privacy}","received_events_url":"https://api.github.com/users/erfannoury/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-03-08T19:06:43Z","updated_at":"2015-03-09T18:29:49Z","closed_at":null,"body":"This issue is created based on discussion in #44.\r\nThere are two objectives that are to be accomplished.\r\n-  [ ] Removing the dependency of existing code on protobuf. \r\n-  [ ] Extend current sample code to include VGG_CNN_S caffemodel converted to theano.\r\n\r\n### Protobuf\r\nThere are two main parts of the code that depend on protobuf.\r\nThe first part is [here](https://github.com/sklearn-theano/sklearn-theano/blob/master/sklearn_theano/feature_extraction/caffe/caffemodel.py#L154:L158), where `caffe_pb2` is loaded so that layer information can be extracted from it. As discussed in the aforementioned PR (#44), this here is the suggested procedure:\r\n>This can be done by writing a function called  `_get_caffe_layer_names `, which returns a  `dict`  indexing layer names to their protobuffer keys and vice versa (as it is done in the code). This function should first look locally for a json file in which this information is coded. If the json file is not present, it should use the  `caffe_pb2`  to create it. In this case it will run into the  `try/except`  case you coded. Implementing this would make  `_parse_caffe_model`  independent from  `caffe_pb2`. \r\n\r\nThe second part is [here](https://github.com/sklearn-theano/sklearn-theano/blob/master/sklearn_theano/feature_extraction/caffe/caffemodel.py#L89:L96), where protobuf is used for parsing the binary content of a `caffemodel` file. Thus, to be able to remove the dependency on protobuf, a parser for `caffemodel` files should be written.\r\n\r\n### VGG_CNN_S\r\nAnother idea is to add this particular model to sklearn-theano. The parser for this new model will be based on what is currently implemented for GoogLeNet, but it might need some modifications and generalizations.\r\n"},"comment":{"url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/comments/77913721","html_url":"https://github.com/sklearn-theano/sklearn-theano/issues/45#issuecomment-77913721","issue_url":"https://api.github.com/repos/sklearn-theano/sklearn-theano/issues/45","id":77913721,"user":{"login":"kastnerkyle","id":1563421,"avatar_url":"https://avatars.githubusercontent.com/u/1563421?v=3","gravatar_id":"","url":"https://api.github.com/users/kastnerkyle","html_url":"https://github.com/kastnerkyle","followers_url":"https://api.github.com/users/kastnerkyle/followers","following_url":"https://api.github.com/users/kastnerkyle/following{/other_user}","gists_url":"https://api.github.com/users/kastnerkyle/gists{/gist_id}","starred_url":"https://api.github.com/users/kastnerkyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kastnerkyle/subscriptions","organizations_url":"https://api.github.com/users/kastnerkyle/orgs","repos_url":"https://api.github.com/users/kastnerkyle/repos","events_url":"https://api.github.com/users/kastnerkyle/events{/privacy}","received_events_url":"https://api.github.com/users/kastnerkyle/received_events","type":"User","site_admin":false},"created_at":"2015-03-09T18:29:49Z","updated_at":"2015-03-09T18:29:49Z","body":"The proto files only change if caffe changes, right? So if we kept the py\nfiles fixed and stored a copy of the model we would basically be keeping a\nkind of snapshot of caffe AND the model itself? We definitely want to avoid\nneeding to keep updated with caffe if possible...\n\nOn Mon, Mar 9, 2015 at 1:56 PM, Erfan Noury <notifications@github.com>\nwrote:\n\n> Could we require that each caffe model store it's own caffe_pb2.py and\n> mynet_pb2.py file?\n> As you can see in #44\n> <https://github.com/sklearn-theano/sklearn-theano/pull/44>, proto files\n> eventually change over time for each model. Thus developer must keep the\n> provided net_pb2.py file updated with the latest proto file.\n>\n> ... see what happens ;)\n> This is what happened:\n>\n> Traceback (most recent call last):\n>   File \"test_googlenet.py\", line 46, in <module>\n>     test_googlenet_classifier()\n>   File \"test_googlenet.py\", line 34, in test_googlenet_classifier\n>     c = GoogLeNetClassifier()\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\googlenet.py\", line 220, in __init__\n>     self.transform_function = _custom_get_fprop(('loss3/loss3',))\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\googlenet.py\", line 112, in _custom_get_fprop\n>     model = _parse_caffe_model(protobuf_file)\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\caffemodel.py\", line 178, in _parse_caffe_model\n>     specifics = LAYER_PROPERTIES[ltype]\n> KeyError: 'SOFTMAX'\n>\n> Thus I added this line to LAYER_PROPERTIES:\n>\n> SOFTMAX=None\n>\n> And then I got this error:\n>\n> Traceback (most recent call last):\n>   File \"test_googlenet.py\", line 46, in <module>\n>     test_googlenet_classifier()\n>   File \"test_googlenet.py\", line 34, in test_googlenet_classifier\n>     c = GoogLeNetClassifier()\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\googlenet.py\", line 220, in __init__\n>     self.transform_function = _custom_get_fprop(('loss3/loss3',))\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\googlenet.py\", line 117, in _custom_get_fprop\n>     verbose=verbose)\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\googlenet.py\", line 90, in create_theano_expressions\n>     layers, blobs, inputs = parse_caffe_model(model, verbose=verbose)\n>   File \"E:\\Code Vault\\Github\\sklearn-theano.old\\sklearn_theano\\feature_extraction\\caffe - Copy\\caffemodel.py\", line 244, in parse_caffe_model\n>     convolution_input = blobs[bottom_blobs[0]]\n> KeyError: u'data'\n>\n> This is a WIP, so will report anything that happens.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/sklearn-theano/sklearn-theano/issues/45#issuecomment-77906635>\n> .\n>\n"}}