MarcBS / keras

Keras' fork with several new functionalities. Caffe2Keras converter, multimodal layers, etc.
https://github.com/MarcBS/keras
Other
225 stars 58 forks source link

Please support the INNER_PRODUCT layer #15

Closed Cod1ng closed 7 years ago

Cod1ng commented 8 years ago

I want to convert the vgg-face caffe model(http://www.robots.ox.ac.uk/~vgg/software/vgg_face/) to keras ,but it reminds me it doesn't support the INNER_PRODUCT layer at this time,please support it ASAP.Thanks!

lemuriandezapada commented 8 years ago

Can't you just use a merge layer with mode = mul? http://keras.io/layers/core/#merge

Cod1ng commented 8 years ago

I mean the Caffe to Keras converter can't process the INNER_PRODUCT layer.If I use other layer to replace it,I don't know how to tranfer the weights in the caffe model to the keras model.

ruslanagit commented 8 years ago

Can anyone please post instructions how to extend the tool to support currently unsupported layer types? @Cod1ng - did you try to add support for INNER_PRODUCT yourself?

I am trying to add support for CROP level. This is where I got:

  1. In file caffe_utils.py: added extra entry in layer_num_to_name
  2. Tried to modify caffe_pb2.py - added a few extra lines, such as: _V1LAYERPARAMETER.fields_by_name['crop_param'].message_type = _CROPPARAMETER DESCRIPTOR.message_types_by_name['CropParameter'] = _CROPPARAMETER (copy paste from other layers, and changing layer name to crop) but then noticed this comment at the beginning of the file: # Generated by the protocol buffer compiler. DO NOT EDIT! # source: caffe.proto and stopped... No idea how to regenerate this file, or what protocol buffer compiler is. Any help would be highly appreciated! @MarcBS - can you help please?
MarcBS commented 8 years ago

The file caffe_pb2.py is generated when you compile the "pycaffe" wrapper for Caffe. You can find it here: /caffe_root_path/python/caffe/proto/caffe_pb2.py

If you need a newer version of it, you just have to compile the latest version of Caffe by yourself and copy it into the corresponding folder of Keras.

I am sorry for not being able to help you implementing these additional features right now, but you are welcome to submit any PR adding useful features to this library!