mllite / keras2sql

Deep Learning (Keras) Models Deployment using SQL databases
BSD 3-Clause "New" or "Revised" License
17 stars 3 forks source link

Add support for convolutions #1

Open antoinecarme opened 6 years ago

antoinecarme commented 6 years ago

Sample use case : simple convnet on the MNIST dataset

keras example : https://github.com/keras-team/keras/blob/master/examples/mnist_cnn.py

used layers and activation functions :

model.add(Conv2D(32, kernel_size=(3, 3),
                 activation='relu',
                 input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
antoinecarme commented 6 years ago

Added a primary implementation which works for small models.

Main pain points (to be solved):

  1. The second Conv2D layer
  2. the Flatten layer is too large (depends on the number of filters used in convolutions : 32 and 64). This layer works for small number of filters (in the jupyter notebook , we use 8 and 0)
  3. When the size of Flatter layer goes above 1000, we have some issues with the databases support for wide tables. => create separate issue (at least for some experiments. May not be solvable).
  4. The Dense layer leads to a very large model and SQL code. Need to perform some feature selection (make sparse models) and some simplification of the SQL code (non-used columns can be deleted).
antoinecarme commented 6 years ago

Another possibility is to perform a compression (exact or approximate) of the model.

new issue => #5