Skip to content
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

How to use representative_dataset_gen() #41

Closed
tu1258 opened this issue Oct 16, 2020 · 0 comments
Closed

How to use representative_dataset_gen() #41

tu1258 opened this issue Oct 16, 2020 · 0 comments

Comments

@tu1258
Copy link

tu1258 commented Oct 16, 2020

I used tf 2.3 and met segmentation fault (core dumped) error when using representative_dataset_gen().
Code

    def representative_dataset_gen():
      for audio in validation_fingerprints:
        yield [audio]
    converter = tf.lite.TFLiteConverter.from_saved_model(flags.train_dir + '/last_model')
    converter.optimizations = [tf.lite.Optimize.DEFAULT]
    converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS]
    converter.allow_custom_ops = True
    converter.inference_input_type = tf.uint8
    converter.inference_output_type = tf.uint8
    # converter.representative_dataset = representative_dataset_gen
    quant_model = converter.convert()
    with open(flags.train_dir + '/quant_last_model.tflite', 'wb') as w:
      w.write(quant_model)

Above code can run without error but if I use converter.representative_dataset = representative_dataset_gen, it fail.

The type and shape of data are at below. The input layer size is [Batch, 16384]

type(validation_fingerprints): <class 'numpy.ndarray'>
shape(validation_fingerprints): (3093, 16384)

Any suggestion?

@tu1258 tu1258 closed this as completed Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant