keras2caffe
keras2caffe copied to clipboard
Error while converting
I got an error while converting as follows:
....
I0107 15:12:23.722321 7166 net.cpp:242] This network produces output dense_2
I0107 15:12:23.722332 7166 net.cpp:255] Network initialization done.
Traceback (most recent call last):
File "/home/sr5/younkyu.lee/keras2caffe/keras2caffe-master/convert_youn.py", line 91, in
Process finished with exit code 1
Please help me resolve this issue..
It's hard to help without knowing of your keras model definition
Here is the model I used:
model = Sequential() model.add(Convolution2D(64, (3, 3), padding='same', input_shape=X_train.shape[1:])) model.add(Activation('relu')) model.add(Convolution2D(64, (3, 3)), padding='same')) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2), padding='same')) model.add(Dropout(0.25))
model.add(Convolution2D(128, (3, 3)padding='same'))
model.add(Activation('relu'))
model.add(Convolution2D(128, (3, 3)), padding='same'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2), padding='same'))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(nb_classes))
model.add(Activation('softmax'))
model.compile(loss='binary_crossentropy', optimizer='adadelta', metrics=['accuracy'])
What is nb_classes and input shape? I will try to reproduce this error.
Thank you for your help.
- nb_classes: 2
- input shape: (60, 60, 1)
Would it be because of the version of tools? I've used:
- Keras 2.2.4
- Tensorflow 1.9.0
- Caffe 1.0
I had no problem converting your model with Keras 2.1.5. You should try it
I have tried mine with 2.1.5 and still got the same error. Could you please share the code for building the model?
import sys
sys.path.append('../../')
import keras2caffe
from keras.models import Sequential. from keras.layers import Convolution2D, Activation, Dropout, Dense, Flatten, MaxPooling2D
nb_classes=2
model = Sequential() #model.add(Convolution2D(64, (3, 3), padding='same', input_shape=X_train.shape[1:])) model.add(Convolution2D(64, (3, 3), padding='same', input_shape=(60, 60, 1))) model.add(Activation('relu')) model.add(Convolution2D(64, (3, 3), padding='same')) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2), padding='same')) model.add(Dropout(0.25))
model.add(Convolution2D(128, (3, 3), padding='same')) model.add(Activation('relu')) model.add(Convolution2D(128, (3, 3), padding='same')) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2), padding='same')) model.add(Dropout(0.25))
model.add(Flatten()) model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.5)) model.add(Dense(nb_classes)) model.add(Activation('softmax'))
model.compile(loss='binary_crossentropy', optimizer='adadelta', metrics=['accuracy'])
keras2caffe.convert(model, 'deploy.prototxt', 'weights.caffemodel') `
i have the same problem @younkyul , and i find that if the "MaxPooling2D" contains "padding='same'" , it can convert well, but it can not work without "padding='same'"