When I looked into Tensorflow Lite, I found that custom operations will be exported as a "flex op" not as a native.
I don't understand what is "flex op" and what is "native". Thank you!
The code related my questions is in https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/toco/tflite/export.cc#L368
See the documentation here: Using TensorFlow Lite with select TensorFlow ops
It's an experimental feature to support TensorFlow ops which are not supported by TensorFlow Lite, by linking and running TensorFlow kernels.
"Flex" is the internal code name for the "Using TensorFlow Lite with select TensorFlow ops" feature.
Related
Is there's any way to convert a Tensorflow Lite model to a normal Tensorflow Model that i can use with Tensorflow.Javascript?
not supported by tfjs official converters as this is considered one-way conversion. but this tool is pretty amazing, although not the easiest to setup: https://github.com/PINTO0309/tflite2tensorflow
I am using tensorflow 1.15 due to dependency on multiple other modules and struggling to do quantize aware training. I came across tensorflow_model_optimization, but it works with tensorflow 2.x. Is there any way Quantization can be performed during training with tensorflow 1.15?
We cannot as quantization aware training was introduced in TF 2.0, so please upgrade to 2.x and let us know if you face any issues. as there is no workaround for it in 1.x.
I want to use mobileNetV2 with tf.keras.
If look on the tensorflow website for keras applications
I find
mobilenet = tf.keras.applications.MobileNetV2()
If I try to import MobileNetV2
from tensorflow.keras.applications import MobileNetV2
I get an error:
ImportError: cannot import name 'MobileNetV2'
If I check the Keras2 webside I do find only a handful of applications. The mobileNetV2 (or V1) is not one of them. But the V1 model can be loaded and used.
If I follow the link on the tensorflow.keras website, it brings me to the classic keras webside which in my opinion is Keras1 not keras2, am I wrong? Also stating MobileNetV2, which apparently is not implemented. So I guess the link is wrong.
This is all confusing to me. Probably, this is all due to due to the switch to tf.keras, or am mixing things up?
To formulate my question more concrete: Is there a predefined, usable MobileNetV2 application with tf.keras or do I have to implement it by hand?
Thanks
edit: TF version 1.10.
You are using this link for your reference for MobileNetV2 but that is documented for tensorflow version 1.13. And you are using tensorflow version 1.10. In this you can only find MobileNet not MobileNetV2.
For tensorflow version 1.10, you can import like this,
from tensorflow.keras.applications.mobilenet import MobileNet
or
model = tf.keras.applications.MobileNet()
If you want to check what are the model are included in tf.keras.applications, you can check github repo with appropriate tensorflow version.
If you want to use MobileNetV2, please upgrade your tensorflow version and you can use as it mentioned in the documentation.
For Google Colab and latest version of tensorflow,
Use:
!pip install keras_applications
.. will install keras-applications >= 1.0.8
For tensorflow version >= 2.5.0, use
from keras.applications.mobilenet_v2 import MobileNetV2
I'm learning TensorFlow and Keras. I'd like to try https://www.amazon.com/Deep-Learning-Python-Francois-Chollet/dp/1617294438/, and it seems to be written in Keras.
Would it be fairly straightforward to convert code to tf.keras?
I'm not more interested in the portability of the code, rather than the true difference between the two.
The difference between tf.keras and keras is the Tensorflow specific enhancement to the framework.
keras is an API specification that describes how a Deep Learning framework should implement certain part, related to the model definition and training.
Is framework agnostic and supports different backends (Theano, Tensorflow, ...)
tf.keras is the Tensorflow specific implementation of the Keras API specification. It adds the framework the support for many Tensorflow specific features like: perfect support for tf.data.Dataset as input objects, support for eager execution, ...
In Tensorflow 2.0 tf.keras will be the default and I highly recommend to start working using tf.keras
At this point tensorflow has pretty much entirely adopted the keras API and for a good reason - it's simple, easy to use and easy to learn, whereas "pure" tensorflow comes with a lot of boilerplate code. And yes, you can use tf.keras without any issues, though you might have to re-work your imports in the code. For instance
from keras.layers.pooling import MaxPooling2D
Would turn into:
from tensorflow.keras.layers import MaxPooling2D
The history of Keras Vs tf.keras is long and twisted.
Keras: Keras is a high-level (easy to use) API, built by Google AI Developer/Researcher, Francois Chollet. Written in Python and capable of running on top of backend engines like TensorFlow, CNTK, or Theano.
TensorFlow: A library, also developed by Google, for the Deep Learning developer Community, for making deep learning applications accessible and usable to public. Open Sourced and available on GitHub.
With the release of Keras v1.1.0, Tensorflow was made default backend engine. That meant: if you installed Keras on your system, you were also installing TensorFlow.
Later, with TensorFlow v1.10.0, for the first time tf.keras submodule was introduced in Tensorflow. The first step in integrating Keras within TensorFlow
With the release of Keras 2.3.0,
first release of Keras in sync with tf.keras
Last major release to support other multi-backend engines
And most importantly, going forward, recommend switching the code from keras to Tensorflow2.0 and tf.keras packages.
Refer this tweet from François Chollet to use tf.keras.
That means,
Change Everywhere
From
from keras.models import Sequential
from keras.models import load_model
To
from tensorflow.keras.models import Sequential
from tensorflow.keras.models import load_model
And In requirements.txt,
tensorflow==2.3.0
*Disclaimer: it might give conflicts if you were using an older version of Keras. Do pip uninstall keras in that case.
I am working on project Audio classifier app. I am beginner in java Also if some one can help me figure out how to extract MFFC features from audio signal I would like give them credit,also provide me contact details if you are interested.
In Android, you can use TensorFlow Lite , a lightweight solution for TensorFlow.
You can convert a TensorFlow model, or Keras model to a TF Lite model ( .tflite ). See here.
This TF Lite model could be inferenced on an Android or iOS device using the TF Lite's Java and Swift API.
It may not support some layers like LSTM or BatchNormalization. Dense and all Conv layers work well.
Another method is using Tensorflow Mobile.
TensorFlow Mobile runs a protocol buffers file ( .pb ). It has been deprecated but can be still used. But, Google suggests its developers to use TF Lite.
You can find a complete tutorial here.