-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STFT
layer output shape deviates from STFTTflite
layer in batch dimension
#130
Comments
Hi, Yeah the restriction to a batch size of one in tflite is enforced and is something that I have been trying to address, but I have been getting seg-faults when running tflite inference so have not yet solved it. If you are interested you can look at my fork for details (work in progress): https://github.com/kenders2000/kapre/tree/feature/tflite-variable-batch-size I recently tried using the tf.signal.stft but it is still not tflite compatible from what I could see. Hope this helps, I agree there is probably a case for improved documentation to explain this. Cheers Paul |
Thanks for your response @kenders2000! I have a follow-up question. I was able to create a batch-compatible TFLite classification model as follows: inputs = keras.layers.Input(input_shape)
x = kapre.STFTTflite(n_fft=1024, hop_length=512, pad_begin=True)(inputs)
x = kapre.MagnitudeTflite()(x)
x = kapre.MagnitudeToDecibel()(x)
x = keras.layers.Flatten()(x)
x = keras.layers.Dense(n_outputs, activation='softmax')(x)
model = keras.models.Model(inputs, x) With the resulting
Do you expect this model to run into seg-faults with inference on mobile devices? Note: this is just a simple example model for simplicity. |
Hi, I can see in the model summary that while the input is E.g. using resize_tensor_input() Cheers Paul |
I see, thanks! |
Thank you so much for everyone! |
Use Case
I want to convert a
STFT
layer in my model to aSTFTTflite
to deploy it to my mobile device. In the documentation I found that another dimension is added to account for complex numbers. But I also encountered a behaviour that is not documented.Expected Behaviour
model
has the output shape(None, 3, 513, 1)
. Therefore,tflite_model
should have the output shape(None, 3, 513, 1, 2)
.Observed Behaviour
The output shape of
tflite_model
is(1, 3, 513, 1, 2)
instead of(None, 3, 513, 1, 2)
.Problem Solution
1
.None
.The text was updated successfully, but these errors were encountered: