pplonski / keras2cpp

This is a bunch of code to port Keras neural network model into pure C++.
MIT License
679 stars 153 forks source link

Compatible for python3 and new keras #40

Open GeorgeKAHChen opened 5 years ago

GeorgeKAHChen commented 5 years ago

For some reason we found this program to change python, keras to cpp. However after we used, we found some problem for this program. On the one hand, there are some little problem on python2 to python3. On the other hand, some subject of the json file of new keras has been changed. And after test, finally, we build a new version on this site

https://github.com/KazukiAmakawa/keras2cpp

djsg commented 5 years ago

@KazukiAmakawa Hi, I tried your package, and got one warning and one error: /data/fitpu/py_vt/tutorial-env/lib/python3.5/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, units=10, kernel_initializer="glorot_uniform", activation="linear", activity_regularizer=None, bias_regularizer=None, bias_constraint=None, use_bias=True, input_dim=None, kernel_constraint=None, name="dense_2") return cls(**config) Traceback (most recent call last): File "dump_to_simple_cpp.py", line 48, in fout.write(str(W.shape[0]) + ' ' + str(W.shape[1]) + ' ' + str(W.shape[2]) + ' ' + str(W.shape[3]) + ' ' + l['config']['padding'] + '\n') KeyError: 'padding'

gosha20777 commented 5 years ago

@KazukiAmakawa Hi, I tried your package, and got one warning and one error: /data/fitpu/py_vt/tutorial-env/lib/python3.5/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, units=10, kernel_initializer="glorot_uniform", activation="linear", activity_regularizer=None, bias_regularizer=None, bias_constraint=None, use_bias=True, input_dim=None, kernel_constraint=None, name="dense_2") return cls(**config) Traceback (most recent call last): File "dump_to_simple_cpp.py", line 48, in fout.write(str(W.shape[0]) + ' ' + str(W.shape[1]) + ' ' + str(W.shape[2]) + ' ' + str(W.shape[3]) + ' ' + l['config']['padding'] + '\n') KeyError: 'padding'

This implementation does not work with python3. See issue #41