Giter Club home page Giter Club logo

keras's People

Contributors

abhaikollara avatar ahundt avatar beareme avatar carlthome avatar edersantana avatar farizrahman4u avatar fchollet avatar fuzzythecat avatar gabrieldemarmiesse avatar gvtulder avatar jfsantos avatar joosephook avatar lukedeo avatar lvapeab avatar marcbs avatar matsuyamax avatar maxpumperla avatar myutwo150 avatar nzw0301 avatar olegsinavski avatar ozabluda avatar pavithrasv avatar phreeza avatar staticskies avatar taehoonlee avatar tdhd avatar the-moliver avatar tleeuwenburg avatar wxs avatar yanboliang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keras's Issues

TypeError: __call__() takes 2 positional arguments but 4 were given

decoder_inputs = Input(shape=((None, num_decoder_tokens)))

decoder_layer = AttGRUCond(latent_dim,return_sequences=True)
decoder_outputs, states = decoder_layer(decoder_inputs,encoder_outputs,state)

decoder_dense = Dense(num_decoder_tokens, activation='softmax')
decoder_seqs = decoder_dense(decoder_outputs)

When using the AttGRUCond layer, the above code snippet yields a type error:

  File "D:/intern/experiments/myAtt_with_custom.py", line 183, in <module>
    decoder_outputs, sts = decoder_layer(decoder_inputs,encoder_outputs,state)

TypeError: __call__() takes 2 positional arguments but 4 were given

I would like to ask if the way using this layer is right? Thanks.

weight decay?

hi Marc,
I'm having trouble figuring out if your code takes into account the weight decay (or decay_mult) parameter of caffe models. That should be L2 weight regularizer right?

deconvolution used in this model is not currently supported

hi, thank you for your share of this useful project!

I notice that you have included DECONVOLUTION in your caffe_utils.py , but the convert is not yet supported. I wonder is their any chance you would like to update this part in the future?

thank you very much!

Error when converting with Scale layer

Traceback (most recent call last):
File "caffe2keras.py", line 49, in
main(arguments)
File "caffe2keras.py", line 35, in main
debug=args.debug)
File "/home/jzh/kk/keras/caffe/convert.py", line 44, in caffe_to_keras
tuple(input_dim[1:]), debug)
File "/home/jzh/kk/keras/caffe/convert.py", line 373, in create_model
net_node[layer_nb] = Scale(axis=axis, name=name)(input_layers)
File "/home/jzh/kk/keras/layers/normalization.py", line 85, in init
self.beta_init = initializations.get(beta_init)
NameError: global name 'initializations' is not defined
I wonder if there is something I should add cause I did not find the (../initializations.md) mentioned in normalization.py

Conversion of PoolingND Layer

I am struggling to convert the below PoolingND of a 3D CNN.

Can you please suggest how can I resolve this issue?

Here is the layer:
layer{ name: "pool1" type: "PoolingND" bottom: "conv1H" top: "pool1" poolingnd_param { pool: MAX kernel_h: 2 kernel_w: 2 kernel_d: 2 stride: 2 } }

NameError: global name 'network_input' is not defined

error occured when trying to convert VGG_TEXT model downloaded from here

Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 45, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_p
ath+'/'+args.caffemodel, debug=args.debug)
File "D:\Program Files\Python27\lib\site-packages\keras-1.0.5-py2.7.egg\keras
caffe\convert.py", line 43, in caffe_to_keras
debug)
File "D:\Program Files\Python27\lib\site-packages\keras-1.0.5-py2.7.egg\keras
caffe\convert.py", line 147, in create_model
dim = get_data_dim(layers[network_input])
NameError: global name 'network_input' is not defined

Error converting Places365 caffe models to keras

Hi,
I'm trying to convert the pre-trained model Places 365 VGG (https://github.com/metalbubble/places365) model but I'm getting the error below.

Do you think the error is related to the converter or to the model? is it something that might be fixed or workarounded somehow?
thanks

python -m  caffe2keras.py -load_path '/tmp/vgg/' -prototxt 'deploy_vgg16_places365.prototxt' -caffemodel 'vgg16_places365.caffemodel'
Using Theano backend.
Converting model...
CREATING MODEL
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 101, in _get_module_details
    loader = get_loader(mod_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/Users/tonizornoza/projects/misc/keras/keras/caffe/caffe2keras.py", line 45, in <module>
    main(args)
  File "/Users/tonizornoza/projects/misc/keras/keras/caffe/caffe2keras.py", line 34, in main
    model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
  File "keras/caffe/convert.py", line 43, in caffe_to_keras
    debug)
  File "keras/caffe/convert.py", line 202, in create_model
    input_layers = Flatten(name=name + '_flatten')(input_layers)
  File "keras/engine/topology.py", line 569, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "keras/engine/topology.py", line 632, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "keras/engine/topology.py", line 168, in create_node
    output_shapes = to_list(outbound_layer.get_output_shape_for(input_shapes[0]))
  File "keras/layers/core.py", line 479, in get_output_shape_for
    '(got ' + str(input_shape[1:]) + '. '
ValueError: The shape of the input to "Flatten" is not fully defined (got (0, 7, 512). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.

Deconvolution layer not supported, while converting caffemodel weight into keras.

HI, I am trying to load caffe_weights .caffemodel file into keras. But getting some errors...

Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 43, in
main(args)
File "caffe2keras.py", line 32, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/rajeev/nabila/keras/keras/caffe/convert.py", line 43, in caffe_to_keras
debug)
File "/home/rajeev/nabila/keras/keras/caffe/convert.py", line 305, in create_model
raise RuntimeError('layer type', type_of_layer, 'used in this model is not currently supported')
RuntimeError: ('layer type', 'deconvolution', 'used in this model is not currently supported')

Is deconvulation layer is not supported till now??
Any help please.

Thanks in Advance.

Error trying to read model from keras/caffe/models/googleNet_structure.json

I am trying to read googleNet model from an example that may be found in the repository, but I get an error

model = model_from_json(open('models/googleNet_structure.json').read())

File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/models.py", line 36, in model_from_json
return layer_from_config(config, custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/utils/layer_utils.py", line 35, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 2271, in from_config
process_layer(layer_data)
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 2249, in process_layer
custom_objects=custom_objects)
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/utils/layer_utils.py", line 35, in layer_from_config
return layer_class.from_config(config['config'])
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 896, in from_config
return cls(**config)
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/layers/convolutional.py", line 283, in init
super(Convolution2D, self).init(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 302, in init
assert kwarg in allowed_kwargs, 'Keyword argument not understood: ' + kwarg
AssertionError: Keyword argument not understood: b_learning_rate_multiplier

Split/slice layer support?

Is there any way to convert a slice layer of caffe into keras? I have used this converter but one of my layer is of slice type which is currently not supported by this converter. I also know that there is no slice/split type in keras but there are other workarounds but I don't know exactly how to solve this issue. Here is my layer:
layer { name: "slice_label" type: SLICE bottom: "label" top: "label_wpqr" top: "label_xyz" slice_param { slice_dim: 1 slice_point: 4 } }

Hi

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Hi, I'm just wondering why you coded like this.

Please make sure that this is a Bug or a Feature Request and provide all applicable information asked by the template.
If your issue is an implementation question, please ask your question on StackOverflow or on the Keras Slack channel instead of opening a GitHub issue.

System information

  • Have I written custom code (as opposed to using example directory):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • TensorFlow backend (yes / no): yes
  • TensorFlow version: 1.4
  • Keras version: 2.2
  • Python version: 3.7
  • CUDA/cuDNN version: 10/forgot
  • GPU model and memory: 16gb

You can obtain the TensorFlow version with:
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
You can obtain the Keras version with:
python -c 'import keras as k; print(k.version)'

Describe the current behavior
In keras/keras/layers/attention.py, line 192
matmul = K.batch_dot(queries_, K.permute_dimensions(keys_, (0, 2, 1)), axes=[2, 1])

Describe the expected behavior
matmul = K.batch_dot(queries_, keys_, , axes=[2, 2])
or
matmul = tf.einsum('ijk,iak->ija',queries_,keys_)
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

Cannot make the conversion tool run

I am trying to convert the U-NET model from caffe to keras.
The model was downloaded from U-NET webpage - here is the direct link

I was trying to run the following command
python caffe2keras.py -load_path 'Downloads\u-net-release' -prototxt 'phseg_v5-train.prototxt' -caffemodel 'phseg_v5.caffemodel'
But ran into multiple issues. Some of the errors include - print errors, import errors, and type errors... (fixing one error just reveals another one...)
I guess my environment just does not support it.
I am running the latest keras with theano backend, on windows 10 and python 3.5
I don't have caffe installation.

Could anyone please help me? Are there any other ways to run the tool? Should I use a different tool in my environment?
Help would be highly appreciated! Thanks.

no module named 'keras_applications'

Traceback (most recent call last):
File "caffe2keras.py", line 1, in
import keras.caffe.convert as convert
File "/home/santosh/Music/poshaq/landmark_detection/new/keras/keras/init.py", line 5, in
from . import applications
File "/home/santosh/Music/poshaq/landmark_detection/new/keras/keras/applications/init.py", line 11, in
import keras_applications
ImportError: No module named 'keras_applications'

If i'm intending on using tensor flow?

I want to convert my caffe network to keras, but this fork only supports this for theano. I'm intending on using the tensorflow backend for my project, and was wondering how i could do that? What would i have to modify in the created models?

I'm not entirely sure what the difference between the two backends are besides the channel ordering.

@MarcBS

convert doesn't seem to generate correct weights

In keras/caffe/convert.py, the function convert_weights never seems to overwrite weights_p with the true value of the weight matrix (if typ == 'convolution'). weights_p is initialized to all zeros on line 337, but never overwritten with blobs[0].data as if the layer was 'inner_product' (line 303).

Dan

NameError: global name 'network_input' is not defined

Hi,
I was trying caffe to keras conversion module that you mentioned but im getting this error when i run the caffe2keras.py

global name 'network_input' is not defined

Any help?

This is the error I get:

python caffe2keras.py -load_path '/path/to.models' -prototxt 'train_val.prototxt' -caffemodel 'bvlc_reference_caffenet.caffemodel'
Using Theano backend.
Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 45, in 
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/dhruv/Desktop/keras/keras/caffe/convert.py", line 42, in caffe_to_keras
debug)
File "/home/dhruv/Desktop/keras/keras/caffe/convert.py", line 138, in create_model
dim = get_data_dim(layers[network_input])
NameError: global name 'network_input' is not defined

I used it to convert caffenet model, the prototxt is this one:
name: "CaffeNet"

force_backward: true
input: "data"
input_dim: 1
input_dim: 3
input_dim: 227
input_dim: 227

input: "label"
input_dim: 1
input_dim: 1
input_dim: 1
input_dim: 1

layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
}
}

layer {
name: "relu1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "norm1"
type: "LRN"
bottom: "pool1"
top: "norm1"
lrn_param {
local_size: 5
alpha: 0.0001
beta: 0.75
}
}
layer {
name: "conv2"
type: "Convolution"
bottom: "norm1"
top: "conv2"
convolution_param {
num_output: 256
pad: 2
kernel_size: 5
group: 2
}
}
layer {
name: "relu2"
type: "ReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "norm2"
type: "LRN"
bottom: "pool2"
top: "norm2"
lrn_param {
local_size: 5
alpha: 0.0001
beta: 0.75
}
}
layer {
name: "conv3"
type: "Convolution"
bottom: "norm2"
top: "conv3"
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
group: 2
}
}
layer {
name: "relu4"
type: "ReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "conv5"
type: "Convolution"
bottom: "conv4"
top: "conv5"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
group: 2
}
}
layer {
name: "relu5"
type: "ReLU"
bottom: "conv5"
top: "conv5"
}
layer {
name: "pool5"
type: "Pooling"
bottom: "conv5"
top: "pool5"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "fc6"
type: "InnerProduct"
bottom: "pool5"
top: "fc6"
inner_product_param {
num_output: 4096
}
}
layer {
name: "relu6"
type: "ReLU"
bottom: "fc6"
top: "fc6"
}
layer {
name: "drop6"
type: "Dropout"
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc7"
type: "InnerProduct"
bottom: "fc6"
top: "fc7"
inner_product_param {
num_output: 4096
}
}

layer {
name: "relu7"
type: "ReLU"
bottom: "fc7"
top: "fc7"
}

layer {
name: "drop7"
type: "Dropout"
bottom: "fc7"
top: "fc7"
dropout_param {
dropout_ratio: 0.5
}
}

layer {
name: "fc8"
type: "InnerProduct"
bottom: "fc7"
top: "fc8"
inner_product_param {
num_output: 1000
}
}

hi when i run test_segmentation.py i receive this error str(n) + ' integers. Received: ' + str(value)) ValueError: The `1st entry of padding` argument must be a tuple of 2 integers. Received: 100

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

No model found in config file when trying to load converted model

I used caffe2keras to convert the VGG16-hybrid1365 caffe model to an h5 file. Conversion went fine and I used the caffemodel and prototxt found here: https://github.com/metalbubble/places365.

However, when I try to load_model, I get ValueError: No model found in config file.

>>> import keras.models
Using Theano backend.
>>> x = keras.models.load_model('keras/keras/caffe/models/Keras_model_weights.h5')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tigress/dchouren/git_sources/keras/keras/models.py", line 140, in load_model
    raise ValueError('No model found in config file.')
ValueError: No model found in config file.

Theano and Keras are up to date.

Any idea why the model is not converted properly?

The only other related issue I could find was this, which didn't shed any light. fchollet/deep-learning-models#1


Converted with

python caffe2keras.py -load_path /tigress/dchouren/thesis/src/keras/keras/caffe/models/ -prototxt deploy_vgg16_hybrid1365.prototxt -caffemodel vgg16_hybrid1365.caffemodel
.
.
.
LOADING WEIGHTS
Finished converting model.
Storing model...
Finished storing the converted model to /tigress/dchouren/thesis/src/keras/keras/caffe/models/

Bug when run caffe2keras

Hi Marc,
I run the caffe2keras function to convert resNext50, but I got the error message as error1, the x is a list instead of a keras tensor, actually it's a structure like [tensor], and if I change the keras backend code to fit this (I change the 492 as shape = x[0].get_shape()), it will get to error2, which still caused by the list type.

Best,
Lele

error1:
(keras_env) lele@istiophorus:~/visualdx_test/keras/keras/caffe$ python caffe2keras.py -load_path /home/lele/visualdx_test/code_resnext -prototxt 'template.prototxt' -caffemodel 'resnext50.caffemodel'
Using TensorFlow backend.
Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 46, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 53, in caffe_to_keras
debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 369, in create_model
net_node[layer_nb] = BatchNormalization(epsilon=epsilon, axis=axis, name=name)(input_layers)
File "/home/lele/visualdx_test/keras/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/home/lele/visualdx_test/keras/keras/layers/normalization.py", line 212, in call
input_shape = K.int_shape(inputs)
File "/home/lele/visualdx_test/keras/keras/backend/tensorflow_backend.py", line 492, in int_shape
shape = x.get_shape()
AttributeError: 'list' object has no attribute 'get_shape'

error2:
(keras_env) lele@istiophorus:~/visualdx_test/keras/keras/caffe$ python caffe2keras.py -load_path /home/lele/visualdx_test/code_resnext -prototxt 'template.prototxt' -caffemodel 'resnext50.caffemodel'
Using TensorFlow backend.
Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 46, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 53, in caffe_to_keras
debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 369, in create_model
net_node[layer_nb] = BatchNormalization(epsilon=epsilon, axis=axis, name=name)(input_layers)
File "/home/lele/visualdx_test/keras/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/home/lele/visualdx_test/keras/keras/layers/normalization.py", line 262, in call
epsilon=self.epsilon)
File "/home/lele/visualdx_test/keras/keras/backend/tensorflow_backend.py", line 1653, in normalize_batch_in_training
shift=None, name=None, keep_dims=False)
File "/home/lele/keras_env/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_impl.py", line 634, in moments
y = math_ops.cast(x, dtypes.float32) if x.dtype == dtypes.float16 else x
AttributeError: 'list' object has no attribute 'dtype'

Unable to convert caffe ResNet model

Moved this from #8 since it doesn't really fit under that topic:

I was able to convert ResNet50 with the current commit and adding the data layer to the model text, but wasn't able to get inference working.

Assuming it was accidentally getting recompiled , I removed the explicit compile step and got this error (same as if replacing mode=0 with mode=2 in the model files):

ValueError: GpuReshape: cannot reshape input of shape (2048) to shape (1, 1, 1, 7).
Apply node that caused the error: GpuReshape{4}(scale5a_branch1_gamma, TensorConstant{[1 1 1 7]})
Toposort index: 447
Inputs types: [CudaNdarrayType(float32, vector), TensorType(int64, vector)]
Inputs shapes: [(2048,), (4,)]
Inputs strides: [(1,), (8,)]
Inputs values: ['not shown', array([1, 1, 1, 7])]
Outputs clients: [[GpuElemwise{Composite{(((i0 * (i1 + i2)) + i3) + ((i4 * i5) + i6))},no_inplace}(GpuReshape{4}.0, GpuElemwise{Composite{(i0 * (i1 / i2))},no_inplace}.0, GpuReshape{4}.0, GpuReshape{4}.0, GpuReshape{4}.0, GpuElemwise{Composite{((i0 * (i1 / i2)) + i3)},no_inplace}.0, GpuReshape{4}.0)]]

only change to test_converted.py was replacing the 3 losses with one when compiling.

model.summary() looks reasonable around that area.

Using tensorflow instead as a backend crashes when trying to load the weights.

ValueError: Shapes (112,) and (64,) are not compatible

python2.7/site-packages/keras/engine/topology.pyc in load_weights(self, filepath, seq_to_functional)
2381 ' elements.')
2382 weight_value_tuples += zip(symbolic_weights, weight_values)
-> 2383 K.batch_set_value(weight_value_tuples)
2384 f.close()
2385

I modified batch_set_value to pass a sanitized version of the name along, and the problem occurs on the first caffe batchnorm scaling layer:

site-packages/tensorflow/python/ops/gen_state_ops.py(45)assign()
43 result = _op_def_lib.apply_op("Assign", ref=ref, value=value,
44 validate_shape=validate_shape,
---> 45 use_locking=use_locking, name=name)
46 return result
47

ipdb> name
u'scale_conv1_scale_conv1_gamma'

So it seems related to the new Scale layer which attempts to replicate caffe's batchnorm+scale division

Caffe2keras.py: ValueError: need more than 3 values to unpack in convert.py

Hi, I tried running the caffe2keras.py file to convert sample caffe model in the project (bvlc_googlenet.caffemodel) using CNTK backend with python 2.7. I get the following error upon running it:

Traceback (most recent call last):
File "caffe2keras.py", line 50, in
main(arguments)
File "caffe2keras.py", line 36, in main
debug=args.debug)
File "C:\Users\rubee\PycharmProjects\kerastest\keras\caffe\convert.py", line 50, in caffe_to_keras
tuple(input_dim[1:]), debug)
File "C:\Users\rubee\PycharmProjects\kerastest\keras\caffe\convert.py", line 300, in create_model
net_node[layer_nb] = LRN2D(alpha=alpha, k=k, beta=beta, n=n, name=name)(input_layers)
File "C:\Users\rubee\PycharmProjects\kerastest\venv\lib\site-packages\keras\engine\base_layer.py", line 460, in call
output = self.call(inputs, **kwargs)
File "C:\Users\rubee\PycharmProjects\kerastest\keras\caffe\extra_layers.py", line 26, in call
b, ch, r, c = input_dim
ValueError: need more than 3 values to unpack

According to this my input_dim array should have 4 dimensions. But it only has 3 dimensions according to the shape input that is (3,500,500). Can you kindly help me out what is wrong over here and what should be the 4th dimension.

Any help in this regard will be highly appreciated.

Looking forward to hear from you.

Regards,
Rabeea

Squeeze net conversion

Is this module able to convert the caffe implementation of squeeze net into keras?

This is the train_val.prototxt:

layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
crop_size: 227
mean_value: 104
mean_value: 117
mean_value: 123
}

}
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
crop_size: 227
mean_value: 104
mean_value: 117
mean_value: 123
}

}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
convolution_param {
num_output: 64
kernel_size: 3
stride: 2
weight_filler {
type: "xavier"
}
}
}
layer {
name: "relu_conv1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "fire2/squeeze1x1"
type: "Convolution"
bottom: "pool1"
top: "fire2/squeeze1x1"
convolution_param {
num_output: 16
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire2/relu_squeeze1x1"
type: "ReLU"
bottom: "fire2/squeeze1x1"
top: "fire2/squeeze1x1"
}
layer {
name: "fire2/expand1x1"
type: "Convolution"
bottom: "fire2/squeeze1x1"
top: "fire2/expand1x1"
convolution_param {
num_output: 64
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire2/relu_expand1x1"
type: "ReLU"
bottom: "fire2/expand1x1"
top: "fire2/expand1x1"
}
layer {
name: "fire2/expand3x3"
type: "Convolution"
bottom: "fire2/squeeze1x1"
top: "fire2/expand3x3"
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire2/relu_expand3x3"
type: "ReLU"
bottom: "fire2/expand3x3"
top: "fire2/expand3x3"
}
layer {
name: "fire2/concat"
type: "Concat"
bottom: "fire2/expand1x1"
bottom: "fire2/expand3x3"
top: "fire2/concat"
}
layer {
name: "fire3/squeeze1x1"
type: "Convolution"
bottom: "fire2/concat"
top: "fire3/squeeze1x1"
convolution_param {
num_output: 16
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire3/relu_squeeze1x1"
type: "ReLU"
bottom: "fire3/squeeze1x1"
top: "fire3/squeeze1x1"
}
layer {
name: "fire3/expand1x1"
type: "Convolution"
bottom: "fire3/squeeze1x1"
top: "fire3/expand1x1"
convolution_param {
num_output: 64
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire3/relu_expand1x1"
type: "ReLU"
bottom: "fire3/expand1x1"
top: "fire3/expand1x1"
}
layer {
name: "fire3/expand3x3"
type: "Convolution"
bottom: "fire3/squeeze1x1"
top: "fire3/expand3x3"
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire3/relu_expand3x3"
type: "ReLU"
bottom: "fire3/expand3x3"
top: "fire3/expand3x3"
}
layer {
name: "fire3/concat"
type: "Concat"
bottom: "fire3/expand1x1"
bottom: "fire3/expand3x3"
top: "fire3/concat"
}
layer {
name: "pool3"
type: "Pooling"
bottom: "fire3/concat"
top: "pool3"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "fire4/squeeze1x1"
type: "Convolution"
bottom: "pool3"
top: "fire4/squeeze1x1"
convolution_param {
num_output: 32
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire4/relu_squeeze1x1"
type: "ReLU"
bottom: "fire4/squeeze1x1"
top: "fire4/squeeze1x1"
}
layer {
name: "fire4/expand1x1"
type: "Convolution"
bottom: "fire4/squeeze1x1"
top: "fire4/expand1x1"
convolution_param {
num_output: 128
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire4/relu_expand1x1"
type: "ReLU"
bottom: "fire4/expand1x1"
top: "fire4/expand1x1"
}
layer {
name: "fire4/expand3x3"
type: "Convolution"
bottom: "fire4/squeeze1x1"
top: "fire4/expand3x3"
convolution_param {
num_output: 128
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire4/relu_expand3x3"
type: "ReLU"
bottom: "fire4/expand3x3"
top: "fire4/expand3x3"
}
layer {
name: "fire4/concat"
type: "Concat"
bottom: "fire4/expand1x1"
bottom: "fire4/expand3x3"
top: "fire4/concat"
}
layer {
name: "fire5/squeeze1x1"
type: "Convolution"
bottom: "fire4/concat"
top: "fire5/squeeze1x1"
convolution_param {
num_output: 32
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire5/relu_squeeze1x1"
type: "ReLU"
bottom: "fire5/squeeze1x1"
top: "fire5/squeeze1x1"
}
layer {
name: "fire5/expand1x1"
type: "Convolution"
bottom: "fire5/squeeze1x1"
top: "fire5/expand1x1"
convolution_param {
num_output: 128
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire5/relu_expand1x1"
type: "ReLU"
bottom: "fire5/expand1x1"
top: "fire5/expand1x1"
}
layer {
name: "fire5/expand3x3"
type: "Convolution"
bottom: "fire5/squeeze1x1"
top: "fire5/expand3x3"
convolution_param {
num_output: 128
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire5/relu_expand3x3"
type: "ReLU"
bottom: "fire5/expand3x3"
top: "fire5/expand3x3"
}
layer {
name: "fire5/concat"
type: "Concat"
bottom: "fire5/expand1x1"
bottom: "fire5/expand3x3"
top: "fire5/concat"
}
layer {
name: "pool5"
type: "Pooling"
bottom: "fire5/concat"
top: "pool5"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "fire6/squeeze1x1"
type: "Convolution"
bottom: "pool5"
top: "fire6/squeeze1x1"
convolution_param {
num_output: 48
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire6/relu_squeeze1x1"
type: "ReLU"
bottom: "fire6/squeeze1x1"
top: "fire6/squeeze1x1"
}
layer {
name: "fire6/expand1x1"
type: "Convolution"
bottom: "fire6/squeeze1x1"
top: "fire6/expand1x1"
convolution_param {
num_output: 192
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire6/relu_expand1x1"
type: "ReLU"
bottom: "fire6/expand1x1"
top: "fire6/expand1x1"
}
layer {
name: "fire6/expand3x3"
type: "Convolution"
bottom: "fire6/squeeze1x1"
top: "fire6/expand3x3"
convolution_param {
num_output: 192
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire6/relu_expand3x3"
type: "ReLU"
bottom: "fire6/expand3x3"
top: "fire6/expand3x3"
}
layer {
name: "fire6/concat"
type: "Concat"
bottom: "fire6/expand1x1"
bottom: "fire6/expand3x3"
top: "fire6/concat"
}
layer {
name: "fire7/squeeze1x1"
type: "Convolution"
bottom: "fire6/concat"
top: "fire7/squeeze1x1"
convolution_param {
num_output: 48
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire7/relu_squeeze1x1"
type: "ReLU"
bottom: "fire7/squeeze1x1"
top: "fire7/squeeze1x1"
}
layer {
name: "fire7/expand1x1"
type: "Convolution"
bottom: "fire7/squeeze1x1"
top: "fire7/expand1x1"
convolution_param {
num_output: 192
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire7/relu_expand1x1"
type: "ReLU"
bottom: "fire7/expand1x1"
top: "fire7/expand1x1"
}
layer {
name: "fire7/expand3x3"
type: "Convolution"
bottom: "fire7/squeeze1x1"
top: "fire7/expand3x3"
convolution_param {
num_output: 192
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire7/relu_expand3x3"
type: "ReLU"
bottom: "fire7/expand3x3"
top: "fire7/expand3x3"
}
layer {
name: "fire7/concat"
type: "Concat"
bottom: "fire7/expand1x1"
bottom: "fire7/expand3x3"
top: "fire7/concat"
}
layer {
name: "fire8/squeeze1x1"
type: "Convolution"
bottom: "fire7/concat"
top: "fire8/squeeze1x1"
convolution_param {
num_output: 64
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire8/relu_squeeze1x1"
type: "ReLU"
bottom: "fire8/squeeze1x1"
top: "fire8/squeeze1x1"
}
layer {
name: "fire8/expand1x1"
type: "Convolution"
bottom: "fire8/squeeze1x1"
top: "fire8/expand1x1"
convolution_param {
num_output: 256
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire8/relu_expand1x1"
type: "ReLU"
bottom: "fire8/expand1x1"
top: "fire8/expand1x1"
}
layer {
name: "fire8/expand3x3"
type: "Convolution"
bottom: "fire8/squeeze1x1"
top: "fire8/expand3x3"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire8/relu_expand3x3"
type: "ReLU"
bottom: "fire8/expand3x3"
top: "fire8/expand3x3"
}
layer {
name: "fire8/concat"
type: "Concat"
bottom: "fire8/expand1x1"
bottom: "fire8/expand3x3"
top: "fire8/concat"
}
layer {
name: "fire9/squeeze1x1"
type: "Convolution"
bottom: "fire8/concat"
top: "fire9/squeeze1x1"
convolution_param {
num_output: 64
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire9/relu_squeeze1x1"
type: "ReLU"
bottom: "fire9/squeeze1x1"
top: "fire9/squeeze1x1"
}
layer {
name: "fire9/expand1x1"
type: "Convolution"
bottom: "fire9/squeeze1x1"
top: "fire9/expand1x1"
convolution_param {
num_output: 256
kernel_size: 1
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire9/relu_expand1x1"
type: "ReLU"
bottom: "fire9/expand1x1"
top: "fire9/expand1x1"
}
layer {
name: "fire9/expand3x3"
type: "Convolution"
bottom: "fire9/squeeze1x1"
top: "fire9/expand3x3"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
weight_filler {
type: "xavier"
}
}
}
layer {
name: "fire9/relu_expand3x3"
type: "ReLU"
bottom: "fire9/expand3x3"
top: "fire9/expand3x3"
}
layer {
name: "fire9/concat"
type: "Concat"
bottom: "fire9/expand1x1"
bottom: "fire9/expand3x3"
top: "fire9/concat"
}
layer {
name: "drop9"
type: "Dropout"
bottom: "fire9/concat"
top: "fire9/concat"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "conv10_new"
type: "Convolution"
bottom: "fire9/concat"
top: "conv10_new"
param {
lr_mult: 5
decay_mult: 1
}
param {
lr_mult: 10
decay_mult: 0
}
convolution_param {
num_output: 100
kernel_size: 1
weight_filler {
type: "gaussian"
mean: 0.0
std: 0.01
}
}
}
layer {
name: "relu_conv10"
type: "ReLU"
bottom: "conv10_new"
top: "conv10_new"
}
layer {
name: "pool10"
type: "Pooling"
bottom: "conv10_new"
top: "pool10"
pooling_param {
pool: AVE
global_pooling: true
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "pool10"
bottom: "label"
top: "loss"

}
layer {
name: โ€œsoftmaxโ€
type: "Softmax"
bottom: "pool10"
top: โ€œsoftmaxโ€

}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "pool10"
bottom: "label"
top: "accuracy"

}
layer {
name: "accuracy_top5"
type: "Accuracy"
bottom: "pool10"
bottom: "label"
top: "accuracy_top5"

accuracy_param {
top_k: 5
}
}

python3 support for caffe2keras

Would you support caffe2keras for python3?

Sample code
python caffe2keras.py -load_path 'models/' -prototxt 'train_val_for_keras.prototxt' -caffemodel 'bvlc_googlenet.caffemodel'

seems not working by that.
For example, print statements missing parenthesis exist in some codes.

Best regards.

Cant convert VGG16 model

I am trying to convert the Places CNN VGG16 model.

Places CNN
Link To VGG16 prototxt and caffemodel

I tried running

python caffe2keras.py -load_path '/root/places/places205VGG16' -prototxt 'deploy_10.prototxt' -caffemodel 'snapshot_iter_765280.caffemodel'

I got the following output

Using Theano backend.
Converting model...
CREATING MODEL
Printing the converted model:
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
conv1_1 (InputLayer)             (None, 3, 224, 224)   0                                            
____________________________________________________________________________________________________
relu1_1 (Activation)             (None, 3, 224, 224)   0           conv1_1[0][0]                    
____________________________________________________________________________________________________
conv1_2_zeropadding (ZeroPadding2(None, 3, 226, 226)   0           relu1_1[0][0]                    
____________________________________________________________________________________________________
conv1_2 (Convolution2D)          (None, 64, 224, 224)  1792        conv1_2_zeropadding[0][0]        
____________________________________________________________________________________________________
relu1_2 (Activation)             (None, 64, 224, 224)  0           conv1_2[0][0]                    
____________________________________________________________________________________________________
pool1 (MaxPooling2D)             (None, 64, 112, 112)  0           relu1_2[0][0]                    
____________________________________________________________________________________________________
conv2_1_zeropadding (ZeroPadding2(None, 64, 114, 114)  0           pool1[0][0]                      
____________________________________________________________________________________________________
conv2_1 (Convolution2D)          (None, 128, 112, 112) 73856       conv2_1_zeropadding[0][0]        
____________________________________________________________________________________________________
relu2_1 (Activation)             (None, 128, 112, 112) 0           conv2_1[0][0]                    
____________________________________________________________________________________________________
conv2_2_zeropadding (ZeroPadding2(None, 128, 114, 114) 0           relu2_1[0][0]                    
____________________________________________________________________________________________________
conv2_2 (Convolution2D)          (None, 128, 112, 112) 147584      conv2_2_zeropadding[0][0]        
____________________________________________________________________________________________________
relu2_2 (Activation)             (None, 128, 112, 112) 0           conv2_2[0][0]                    
____________________________________________________________________________________________________
pool2 (MaxPooling2D)             (None, 128, 56, 56)   0           relu2_2[0][0]                    
____________________________________________________________________________________________________
conv3_1_zeropadding (ZeroPadding2(None, 128, 58, 58)   0           pool2[0][0]                      
____________________________________________________________________________________________________
conv3_1 (Convolution2D)          (None, 256, 56, 56)   295168      conv3_1_zeropadding[0][0]        
____________________________________________________________________________________________________
relu3_1 (Activation)             (None, 256, 56, 56)   0           conv3_1[0][0]                    
____________________________________________________________________________________________________
conv3_2_zeropadding (ZeroPadding2(None, 256, 58, 58)   0           relu3_1[0][0]                    
____________________________________________________________________________________________________
conv3_2 (Convolution2D)          (None, 256, 56, 56)   590080      conv3_2_zeropadding[0][0]        
____________________________________________________________________________________________________
relu3_2 (Activation)             (None, 256, 56, 56)   0           conv3_2[0][0]                    
____________________________________________________________________________________________________
conv3_3_zeropadding (ZeroPadding2(None, 256, 58, 58)   0           relu3_2[0][0]                    
____________________________________________________________________________________________________
conv3_3 (Convolution2D)          (None, 256, 56, 56)   590080      conv3_3_zeropadding[0][0]        
____________________________________________________________________________________________________
relu3_3 (Activation)             (None, 256, 56, 56)   0           conv3_3[0][0]                    
____________________________________________________________________________________________________
pool3 (MaxPooling2D)             (None, 256, 28, 28)   0           relu3_3[0][0]                    
____________________________________________________________________________________________________
conv4_1_zeropadding (ZeroPadding2(None, 256, 30, 30)   0           pool3[0][0]                      
____________________________________________________________________________________________________
conv4_1 (Convolution2D)          (None, 512, 28, 28)   1180160     conv4_1_zeropadding[0][0]        
____________________________________________________________________________________________________
relu4_1 (Activation)             (None, 512, 28, 28)   0           conv4_1[0][0]                    
____________________________________________________________________________________________________
conv4_2_zeropadding (ZeroPadding2(None, 512, 30, 30)   0           relu4_1[0][0]                    
____________________________________________________________________________________________________
conv4_2 (Convolution2D)          (None, 512, 28, 28)   2359808     conv4_2_zeropadding[0][0]        
____________________________________________________________________________________________________
relu4_2 (Activation)             (None, 512, 28, 28)   0           conv4_2[0][0]                    
____________________________________________________________________________________________________
conv4_3_zeropadding (ZeroPadding2(None, 512, 30, 30)   0           relu4_2[0][0]                    
____________________________________________________________________________________________________
conv4_3 (Convolution2D)          (None, 512, 28, 28)   2359808     conv4_3_zeropadding[0][0]        
____________________________________________________________________________________________________
relu4_3 (Activation)             (None, 512, 28, 28)   0           conv4_3[0][0]                    
____________________________________________________________________________________________________
pool4 (MaxPooling2D)             (None, 512, 14, 14)   0           relu4_3[0][0]                    
____________________________________________________________________________________________________
conv5_1_zeropadding (ZeroPadding2(None, 512, 16, 16)   0           pool4[0][0]                      
____________________________________________________________________________________________________
conv5_1 (Convolution2D)          (None, 512, 14, 14)   2359808     conv5_1_zeropadding[0][0]        
____________________________________________________________________________________________________
relu5_1 (Activation)             (None, 512, 14, 14)   0           conv5_1[0][0]                    
____________________________________________________________________________________________________
conv5_2_zeropadding (ZeroPadding2(None, 512, 16, 16)   0           relu5_1[0][0]                    
____________________________________________________________________________________________________
conv5_2 (Convolution2D)          (None, 512, 14, 14)   2359808     conv5_2_zeropadding[0][0]        
____________________________________________________________________________________________________
relu5_2 (Activation)             (None, 512, 14, 14)   0           conv5_2[0][0]                    
____________________________________________________________________________________________________
conv5_3_zeropadding (ZeroPadding2(None, 512, 16, 16)   0           relu5_2[0][0]                    
____________________________________________________________________________________________________
conv5_3 (Convolution2D)          (None, 512, 14, 14)   2359808     conv5_3_zeropadding[0][0]        
____________________________________________________________________________________________________
relu5_3 (Activation)             (None, 512, 14, 14)   0           conv5_3[0][0]                    
____________________________________________________________________________________________________
pool5 (MaxPooling2D)             (None, 512, 7, 7)     0           relu5_3[0][0]                    
____________________________________________________________________________________________________
fc6_flatten (Flatten)            (None, 25088)         0           pool5[0][0]                      
____________________________________________________________________________________________________
fc6 (Dense)                      (None, 4096)          102764544   fc6_flatten[0][0]                
____________________________________________________________________________________________________
relu6 (Activation)               (None, 4096)          0           fc6[0][0]                        
____________________________________________________________________________________________________
drop6 (Dropout)                  (None, 4096)          0           relu6[0][0]                      
____________________________________________________________________________________________________
fc7 (Dense)                      (None, 4096)          16781312    drop6[0][0]                      
____________________________________________________________________________________________________
relu7 (Activation)               (None, 4096)          0           fc7[0][0]                        
____________________________________________________________________________________________________
drop7 (Dropout)                  (None, 4096)          0           relu7[0][0]                      
____________________________________________________________________________________________________
fc8 (Dense)                      (None, 205)           839885      drop7[0][0]                      
____________________________________________________________________________________________________
prob (Activation)                (None, 205)           0           fc8[0][0]                        
====================================================================================================
Total params: 135063501
____________________________________________________________________________________________________

LOADING WEIGHTS



Traceback (most recent call last):
  File "caffe2keras.py", line 45, in <module>
    main(args)
  File "caffe2keras.py", line 34, in main
    model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/caffe/convert.py", line 64, in caffe_to_keras
    load_weights(model, weights)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/caffe/convert.py", line 455, in load_weights
    model.get_layer(layer.name).set_weights(weights[layer.name])
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 879, in set_weights
    ' weights. Provided weights: ' + str(weights)[:50] + '...')
Exception: You called `set_weights(weights)` on layer "conv1_1" with a  weight list of length 2, but the layer was expecting 0 weights. Provided weights: [array([[[[ -6.61635473e-02,  -6.69440255e-02,  -2...

TypeError: expected bytes, str found

File "/usr/local/lib/python3.5/dist-packages/google/protobuf/descriptor.py", line 829, in new
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: expected bytes, str found

Error converting caffe model

I'm getting an exeception for unknown node/input identifier: data

$python keras/caffe/caffe2keras.py -load_path "/Users/mike/Research/models/bvlc_googlenet" -prototxt train_val.prototxt -caffemodel bvlc_googlenet.caffemodel
Using Theano backend.
Couldn't import dot_parser, loading of dot files will not be possible.
/Users/mike/.virtualenvs/caffe/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:5: UserWarning: downsample module has been moved to the pool module.
  warnings.warn("downsample module has been moved to the pool module.")
Converting model...
Traceback (most recent call last):
  File "keras/caffe/caffe2keras.py", line 45, in <module>
    main(args)
  File "keras/caffe/caffe2keras.py", line 34, in main
    model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
  File "/Users/mike/Research/packages/caffe_to_keras/keras/caffe/convert.py", line 43, in caffe_to_keras
    debug)
  File "/Users/mike/Research/packages/caffe_to_keras/keras/caffe/convert.py", line 183, in create_model
    model.add_node(ZeroPadding2D(padding=(pad_h, pad_w)), name=name + '_zeropadding', input=input_layer_name)
  File "/Users/mike/Research/packages/caffe_to_keras/keras/layers/containers.py", line 357, in add_node
    raise Exception('Unknown node/input identifier: ' + input)
Exception: Unknown node/input identifier: data

the accuracy decrease appearently after converting caffe to keras.

I have converted a model in caffe to Keras model using your projection. The caffe model on LFW has a accuracy of 98.2%, but after converting to keras, the accuracy on LFW is only 80%. The pre-processing methods for both model are the same. I have also tried other converting code to convert caffe model to keras, but all the results are similar, the accuracy decreases to 77%~ 80%.
I don't know why this would happen. Is there any caution I should care? Or some others I have missed?
Help for your response, thanks!

Negative dimension size for 'pool2/MaxPool' (op: 'MaxPool') with input shapes:[?,1,112,128].

Converting model...
[name: "data"
type: "Input"
top: "data"
input_param {
shape {
dim: 1
dim: 3
dim: 224
dim: 224
}
}
, name: "conv1_1"
type: "Convolution"
bottom: "data"
top: "conv1_1"
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
}
, name: "relu1_1"
type: "ReLU"
bottom: "conv1_1"
top: "conv1_1"
, name: "conv1_2"
type: "Convolution"
bottom: "conv1_1"
top: "conv1_2"
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
}
, name: "relu1_2"
type: "ReLU"
bottom: "conv1_2"
top: "conv1_2"
, name: "pool1"
type: "Pooling"
bottom: "conv1_2"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
, name: "conv2_1"
type: "Convolution"
bottom: "pool1"
top: "conv2_1"
convolution_param {
num_output: 128
pad: 1
kernel_size: 3
}
, name: "relu2_1"
type: "ReLU"
bottom: "conv2_1"
top: "conv2_1"
, name: "conv2_2"
type: "Convolution"
bottom: "conv2_1"
top: "conv2_2"
convolution_param {
num_output: 128
pad: 1
kernel_size: 3
}
, name: "relu2_2"
type: "ReLU"
bottom: "conv2_2"
top: "conv2_2"
, name: "pool2"
type: "Pooling"
bottom: "conv2_2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
, name: "conv3_1"
type: "Convolution"
bottom: "pool2"
top: "conv3_1"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
}
, name: "relu3_1"
type: "ReLU"
bottom: "conv3_1"
top: "conv3_1"
, name: "conv3_2"
type: "Convolution"
bottom: "conv3_1"
top: "conv3_2"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
}
, name: "relu3_2"
type: "ReLU"
bottom: "conv3_2"
top: "conv3_2"
, name: "conv3_3"
type: "Convolution"
bottom: "conv3_2"
top: "conv3_3"
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
}
, name: "relu3_3"
type: "ReLU"
bottom: "conv3_3"
top: "conv3_3"
, name: "pool3"
type: "Pooling"
bottom: "conv3_3"
top: "pool3"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
, name: "conv4_1"
type: "Convolution"
bottom: "pool3"
top: "conv4_1"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu4_1"
type: "ReLU"
bottom: "conv4_1"
top: "conv4_1"
, name: "conv4_2"
type: "Convolution"
bottom: "conv4_1"
top: "conv4_2"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu4_2"
type: "ReLU"
bottom: "conv4_2"
top: "conv4_2"
, name: "conv4_3"
type: "Convolution"
bottom: "conv4_2"
top: "conv4_3"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu4_3"
type: "ReLU"
bottom: "conv4_3"
top: "conv4_3"
, name: "pool4"
type: "Pooling"
bottom: "conv4_3"
top: "pool4"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
, name: "conv5_1"
type: "Convolution"
bottom: "pool4"
top: "conv5_1"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu5_1"
type: "ReLU"
bottom: "conv5_1"
top: "conv5_1"
, name: "conv5_2"
type: "Convolution"
bottom: "conv5_1"
top: "conv5_2"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu5_2"
type: "ReLU"
bottom: "conv5_2"
top: "conv5_2"
, name: "conv5_3"
type: "Convolution"
bottom: "conv5_2"
top: "conv5_3"
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
, name: "relu5_3"
type: "ReLU"
bottom: "conv5_3"
top: "conv5_3"
, name: "pool5"
type: "Pooling"
bottom: "conv5_3"
top: "pool5"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
, name: "fc6"
type: "InnerProduct"
bottom: "pool5"
top: "fc6"
inner_product_param {
num_output: 4096
}
, name: "relu6"
type: "ReLU"
bottom: "fc6"
top: "fc6"
, name: "drop6"
type: "Dropout"
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
, name: "fc7"
type: "InnerProduct"
bottom: "fc6"
top: "fc7"
inner_product_param {
num_output: 4096
}
, name: "relu7"
type: "ReLU"
bottom: "fc7"
top: "fc7"
, name: "drop7"
type: "Dropout"
bottom: "fc7"
top: "fc7"
dropout_param {
dropout_ratio: 0.5
}
, name: "fc8_softlabel"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_softlabel"
inner_product_param {
num_output: 20
}
, name: "softmax"
type: "Softmax"
bottom: "fc8_softlabel"
top: "fc8_softlabel"
, name: "fc8_landmarks"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_landmarks"
inner_product_param {
num_output: 12
}
, name: "fc8_visibility_1"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_1"
inner_product_param {
num_output: 3
}
, name: "fc8_visibility_2"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_2"
inner_product_param {
num_output: 3
}
, name: "fc8_visibility_3"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_3"
inner_product_param {
num_output: 3
}
, name: "fc8_visibility_4"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_4"
inner_product_param {
num_output: 3
}
, name: "fc8_visibility_5"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_5"
inner_product_param {
num_output: 3
}
, name: "fc8_visibility_6"
type: "InnerProduct"
bottom: "fc7"
top: "fc8_visibility_6"
inner_product_param {
num_output: 3
}
, name: "fc8"
type: "Concat"
bottom: "fc8_landmarks"
bottom: "fc8_visibility_1"
bottom: "fc8_visibility_2"
bottom: "fc8_visibility_3"
bottom: "fc8_visibility_4"
bottom: "fc8_visibility_5"
bottom: "fc8_visibility_6"
top: "fc8"
]
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 49, in
main(arguments)
File "caffe2keras.py", line 35, in main
debug=args.debug)
File "/root/santosh/try/keras/keras/caffe/convert.py", line 44, in caffe_to_keras
tuple(input_dim[1:]), debug)
File "/root/santosh/try/keras/keras/caffe/convert.py", line 320, in create_model
padding=border_mode, name=name)(input_layers)
File "/root/santosh/try/keras/keras/engine/base_layer.py", line 460, in call
output = self.call(inputs, **kwargs)
File "/root/santosh/try/keras/keras/layers/pooling.py", line 158, in call
data_format=self.data_format)
File "/root/santosh/try/keras/keras/layers/pooling.py", line 221, in _pooling_function
pool_mode='max')
File "/root/santosh/try/keras/keras/backend/tensorflow_backend.py", line 4210, in pool2d
data_format=tf_data_format)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 2142, in max_pool
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 4604, in max_pool
data_format=data_format, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1734, in init
control_input_ops)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op
raise ValueError(str(e))
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'pool2/MaxPool' (op: 'MaxPool') with input shapes: [?,1,112,128].

Enum type "caffe.V1LayerParameter.LayerType" has no value named "CONVOLUTION".

model: http://www.robots.ox.ac.uk/~vgg/software/vgg_face/src/vgg_face_caffe.tar.gz

error:
Traceback (most recent call last):
File "caffe2keras.py", line 45, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/Keras-1.0.5-py2.7.egg/keras/caffe/convert.py", line 29, in caffe_to_keras
google.protobuf.text_format.Merge(prototext, config)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 265, in Merge
return MergeLines(text.split('\n'), message)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 298, in MergeLines
_ParseOrMerge(lines, message, True)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 229, in _ParseOrMerge
_MergeField(tokenizer, message, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 382, in _MergeField
_MergeField(tokenizer, sub_message, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 384, in _MergeField
_MergeScalarField(tokenizer, message, field, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 434, in _MergeScalarField
value = tokenizer.ConsumeEnum(field)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 712, in ConsumeEnum
raise self._ParseError(str(e))
google.protobuf.text_format.ParseError: 11:9 : Enum type "caffe.V1LayerParameter.LayerType" has no value named "CONVOLUTION".

Please provide to Input either a `shape` or a `batch_shape` argument. Note that `shape` does not include the batch dimension.

Hi MarcBS, I am trying to convert this model, at first I got error that no module fft found for from theano.tensor.fft import ifft in backend/theano_backend.py even though import theano.tensor was working, So I commented this line thinking it was of no use (edge of being novice -- Itried adding path and installing theano apart from keras(origional) etc)
After that following error came up while I do not think there is any shape argument required (please note that .caffemodel file is also named 'keras' only )

qayyum@qayyum:~/keras/keras/caffe$ python caffe2keras.py -load_path '/home/qayyum/colorization/' -prototxt 'colorization_deploy_v2.prototxt' -caffemodel 'keras' Using Theano backend. Converting model... CREATING MODEL Traceback (most recent call last): File "caffe2keras.py", line 45, in <module> main(args) File "caffe2keras.py", line 34, in main model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug) File "/home/qayyum/keras/keras/caffe/convert.py", line 43, in caffe_to_keras debug) File "/home/qayyum/keras/keras/caffe/convert.py", line 149, in create_model net_node[layer_nb] = Input(shape=dim, name=name) File "/home/qayyum/keras/keras/engine/topology.py", line 1083, in Input 'shapedoes not include the batch ' AssertionError: Please provide to Input either ashapeor abatch_shapeargument. Note thatshapedoes not include the batch dimension.

Problems in Inferring input shape in caffe_to_keras function in convert.py

Hey Marc!
I'm having some trouble with the convert.py function, specifically, "tuple(config.input_dim[1:])" gives me an empty list as an output.
To reproduce the error, I used ipdb and set a breakpoint ->

def caffe_to_keras(prototext, caffemodel, phase='train', debug=False)

    config = caffe.NetParameter()
    prototext = preprocessPrototxt(prototext, debug)
    text_format.Merge(prototext, config)

    if len(config.layers) != 0:
        raise Exception("Prototxt files V1 are not supported.")
        layers = config.layers[:]   # prototext V1
    elif len(config.layer) != 0:
        layers = config.layer[:]    # prototext V2
    else:
        raise Exception('could not load any layers from prototext')


    import ipdb; ipdb.set_trace()  # breakpoint 49be92bd //
    print("CREATING MODEL")
    model = create_model(layers,
                              0 if phase == 'train' else 1,
                              tuple(config.input_dim[1:]),
                             debug)

ipdb> config.input_dim[0:]
[]

`

I tried it with both debug.prototxt and train_val_for_keras.prototxt , and faced the same issue, any suggestions on how to fix it? I'm temporarily passing a fixed value of [None, 3, 500, 500] to the create model function.

Enum type "caffe.V1LayerParameter.LayerType" has no value named "DATA".

Caffe model: http://vision.princeton.edu/pvt/GoogLeNet/ImageNet/

Error:

Traceback (most recent call last):
File "caffe2keras.py", line 45, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/Keras-1.0.5-py2.7.egg/keras/caffe/convert.py", line 29, in caffe_to_keras
google.protobuf.text_format.Merge(prototext, config)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 265, in Merge
return MergeLines(text.split('\n'), message)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 298, in MergeLines
_ParseOrMerge(lines, message, True)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 229, in _ParseOrMerge
_MergeField(tokenizer, message, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 382, in _MergeField
_MergeField(tokenizer, sub_message, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 384, in _MergeField
_MergeScalarField(tokenizer, message, field, allow_multiple_scalars)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 434, in _MergeScalarField
value = tokenizer.ConsumeEnum(field)
File "/home/vladimir/packages/2/keras/keras2caffe/local/lib/python2.7/site-packages/google/protobuf/text_format.py", line 712, in ConsumeEnum
raise self._ParseError(str(e))
google.protobuf.text_format.ParseError: 4:9 : Enum type "caffe.V1LayerParameter.LayerType" has no value named "DATA".

Use non-standard version of caffe for model conversion.

I used non-standard version of caffe for training my model. When I tried to convert it to keras model, this is the error I got : "caffe.LayerParameter" has no field named "transpose_param". Could you please tell me how can I use caffe2keras.py script specifying a different built of caffe.

Error when converting places205VGG to keras

Hello everybody,

I would like to convert Places250CNN and hybridCNN (http://places.csail.mit.edu/downloadCNN.html) to keras model but i found this error. Can you help me please.

====================
Total params: 135,063,501
Trainable params: 135,063,501
Non-trainable params: 0


LOADING WEIGHTS
Traceback (most recent call last):
File "caffe2keras.py", line 43, in
main(args)
File "caffe2keras.py", line 32, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/nabila/keras/keras/caffe/convert.py", line 64, in caffe_to_keras
load_weights(model, weights)
File "/home/nabila/keras/keras/caffe/convert.py", line 455, in load_weights
model.get_layer(layer.name).set_weights(weights[layer.name])
File "/home/nabila/keras/keras/engine/topology.py", line 966, in set_weights
str(weights)[:50] + '...')
ValueError: You called set_weights(weights) on layer "conv1_1" with a weight list of length 2, but the layer was expecting 0 weights. Provided weights: [array([[[[ -6.61635473e-02, -6.69440255e-02, -2...

when i run test_segmentation.py i receive this essor str(n) + ' integers. Received: ' + str(value)) ValueError: The `1st entry of padding` argument must be a tuple of 2 integers. Received: 100

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Error when converting with merge layer

Hi,

When I try to convert my caffe model I receive the following error:
ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, -1L, 27L, 64), (None, -1L, 27L, 128), (None, -1L, 27L, 32), (None, -1L, 27L, 32)]

It is quite strange that in the shape of the layer contains an L and is -1.

[Meta] Why is caffe2keras part of a keras fork?

Seems to me this tool doesn't need access to keras internals, so I'm not sure why it's part of a keras fork. I made some changes to the tool that could be useful, but I couldn't fork this repository since I already forked the original keras.

Problem in converting V2 models

I was trying to convert the following model.

https://github.com/yjxiong/caffe/tree/action_recog/models/action_recognition

Both these models are working fine with the main and latest version of caffe via python interface.

I got the following error:


LOADING WEIGHTS
Traceback (most recent call last):
  File "caffe2keras.py", line 45, in <module>
    main(args)
  File "caffe2keras.py", line 34, in main
    model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/caffe/convert.py", line 62, in caffe_to_keras
    weights = convert_weights(param_layers, v, debug)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/caffe/convert.py", line 395, in convert_weights
    nb_filter = int(blobs[0].shape.dim[0])
  File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/containers.py", line 64, in __getitem__
    return self._values[key]
IndexError: list index out of range

Recurrent dropout is broken in (at least) AttGRUCond

Traceback (most recent call last):
File "main.py", line 354, in
train_model(parameters)
File "main.py", line 37, in train_model
store_path=params['STORE_PATH'])
File "/home/machirio/NMT/nmt-keras/model_zoo.py", line 102, in init
eval('self.' + type + '(params)')
File "", line 1, in
File "/home/machirio/NMT/nmt-keras/model_zoo.py", line 364, in GroundHogModel
rnn_output = sharedAttRNNCond(input_attentional_decoder)
File "/home/machirio/NMT/keras/keras/engine/topology.py", line 569, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/machirio/NMT/keras/keras/engine/topology.py", line 632, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/machirio/NMT/keras/keras/engine/topology.py", line 170, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))
File "/home/machirio/NMT/keras/keras/layers/recurrent.py", line 1340, in call
constants, B_V = self.get_constants(state_below, mask[1])
File "/home/machirio/NMT/keras/keras/layers/recurrent.py", line 1447, in get_constants
input_shape = self.input_spec[0][0].shape

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.