本文主要是介绍TfLite: 把pb、h5文件转换为TfLite格式and quantilize,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
现在不是都用keras生成h5格式文件,然后用tflite_convert 吗?
问题来源
写了个很简单的RNN LSTM 模型
input = keras.Input(shape=(X_train.shape[1], X_train.shape[2]))
x = layers.LSTM(64, return_sequences = True)(input)
x = layers.LSTM(64)(x)
output = layers.Dense(6, activation='softmax')(x)
model = keras.Model(inputs=input, outputs=output)
model.summary()
Model: "model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_2 (InputLayer) [(None, 200, 3)] 0
_________________________________________________________________
lstm_1 (LSTM) (None, 200, 64) 17408
_________________________________________________________________
lstm_2 (LSTM) (None, 64) 33024
_________________________________________________________________
dense (Dense) (None, 6) 390
=================================================================
出现如下错误
In [102]: model = keras.models.load_model('ar_model.h5')
In [103]: converter = tf.lite.TFLiteConverter.from_keras_model(model)
In [104]: tflite_model = converter.convert()
2019-07-04 18:27:11.251237: I tensorflow/core/grappler/devices.cc:60] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA support)
2019-07-04 18:27:11.251429: I tensorflow/core/grappler/clusters/single_machine.cc:359] Starting new session
2019-07-04 18:27:11.266766: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize
2019-07-04 18:27:11.266814: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] function_optimizer: Graph size after: 437 nodes (262), 654 edges (442), time = 8.606ms.
2019-07-04 18:27:11.266822: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] function_optimizer: function_optimizer did nothing. time = 0.551ms.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-104-c548bab089a8> in <module>()
----> 1 tflite_model = converter.convert()
/usr/local/lib/python2.7/dist-packages/tensorflow/lite/python/lite.pyc in convert(self)
346
347 frozen_func = _convert_to_constants.convert_variables_to_constants_v2(
--> 348 self._funcs[0])
349 input_tensors = [
350 tensor for tensor in frozen_func.inputs
/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/convert_to_constants.pyc in convert_variables_to_constants_v2(func)
164 input_name = get_name(map_name_to_node[input_name].input[0])
165 if map_name_to_node[input_name].op != "Placeholder":
--> 166 raise ValueError("Cannot find the Placeholder op that is an input "
167 "to the ReadVariableOp.")
168 # Build a map of Placeholder ops that are inputs to ReadVariableOps to the
ValueError: Cannot find the Placeholder op that is an input to the ReadVariableOp.
LSTM并不是所有的类型都支持,该模型的底层实现使用了?
https://www.tensorflow.org/lite/convert/rnn
怎样看keras的实现使用的是什么operator?
使用Tensorflow构建模型,控制使用的LSTM类型
https://medium.com/@curiousily/human-activity-recognition-using-lstms-on-android-tensorflow-for-hackers-part-vi-492da5adef64
# Stack 2 LSTM layers
lstm_layers = [tf.contrib.rnn.BasicLSTMCell(N_HIDDEN_UNITS, forget_bias=1.0)
for _ in range(2)]
lstm_layers = tf.contrib.rnn.MultiRNNCell(lstm_layers)
outputs, _ = tf.contrib.rnn.static_rnn(lstm_layers, hidden, dtype=tf.float32)
# Get output for the last time step lstm_last_output = outputs[-1]
怎样把得到的pb文件转化成tflite
https://zhuanlan.zhihu.com/p/59496851
这篇提到使用bazel build生成源码相关的工具,感觉比较靠谱,关键是bazel 还算熟悉
查看模型结构的工具:得到toco的输入参数
$ bazel build tensorflow/tools/graph_transforms:summarize_graph
格式转化的工具
$ bazel build tensorflow/lite/toco:toco
bin文件编出后,可以copy到需要的路径下,如pb文件所在的路径
./summarize_graph --in_graph=frozen_har.pb
Found 1 possible inputs: (name=input, type=float(1), shape=[?,200,3])
No variables spotted.
Found 1 possible outputs: (name=y_, op=Softmax)
Found 67919 (67.92k) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 1230 Const, 1200 Mul, 1200 Sigmoid, 802 Add, 800 Tanh, 404 ConcatV2, 402 MatMul, 401 Split, 400 BiasAdd, 8 Identity, 4 ExpandDims, 4 Fill, 1 Transpose, 1 StridedSlice, 1 Softmax, 1 Shape, 1 Reshape, 1 Relu, 1 Placeholder
To use with tensorflow/tools/benchmark:benchmark_model try these arguments:
bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=frozen_har.pb --show_flops --input_layer=input --input_layer_type=float --input_layer_shape=-1,200,3 --output_layer=y_
toco的基本参数意义(主要里面有废弃的参数)
--input_file=""
string
Input file (model of any supported format).
For Protobuf formats, both text and binary are supported regardless of file extension.
--output_file=""
string
Output file. For Protobuf formats, the binary format will be used.
--output_format="TFLITE"
string
Output file format. One of TENSORFLOW_GRAPHDEF, TFLITE, GRAPHVIZ_DOT.
--inference_type=""
string
Target data type of arrays in the output file (for input_arrays, this may be overridden by inference_input_type).
One of FLOAT, QUANTIZED_UINT8.
--inference_input_type=""
string
Target data type of input arrays. If not specified, inference_type is used. One of FLOAT, QUANTIZED_UINT8.
--input_arrays=""
string
Names of the input arrays, comma-separated. If not specified, will try to read that information from the input file.
--output_arrays=""
string Names of the output arrays, comma-separated. If not specified,
will try to read that information from the input file.
--input_shapes=""
string
Shapes corresponding to --input_arrays, colon-separated. For many models each shape takes the form batch size, input array height, input array width, input array depth.
--input_data_types=""
string
Input arrays types, comma-separated, if not already provided in the graph.
Typically needs to be specified when passing arbitrary arrays to --input_arrays.
input_shapes=[?,200,3]
这里写 ?、-1还是1, 从错误信息看出应该写1
./toco --input_file="frozen_har.pb" --output_file="frozen_har.tflite" --input_format="TENSORFLOW_GRAPHDEF" --output_format="TFLITE" --inference_type="FLOAT" --input_shapes="-1,200,3" --input_arrays="input" --output_arrays="y_"
2019-07-05 17:36:16.423579: F tensorflow/lite/toco/tooling_util.cc:622] Check failed: dim >= 1 (-1 vs. 1)
执行过程、结果
./toco --input_file="frozen_har.pb" --output_file="frozen_har.tflite" --input_format="TENSORFLOW_GRAPHDEF" --output_format="TFLITE" --inference_type="FLOAT" --input_shapes="1,200,3" --input_arrays="input" --output_arrays="y_"
2019-07-05 17:36:54.449902: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 5631 operators, 8261 arrays (0 quantized)
2019-07-05 17:36:58.338339: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 5631 operators, 8261 arrays (0 quantized)
2019-07-05 17:37:07.555026: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 5220 operators, 8241 arrays (0 quantized)
2019-07-05 17:37:15.311358: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 2: 5219 operators, 8240 arrays (0 quantized)
2019-07-05 17:37:23.238861: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 3: 5196 operators, 8201 arrays (0 quantized)
2019-07-05 17:37:31.016187: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before dequantization graph transformations: 5196 operators, 8201 arrays (0 quantized)
2019-07-05 17:37:32.857134: I tensorflow/lite/toco/allocate_transient_arrays.cc:345] Total transient array allocated size: 102400 bytes, theoretical optimal value: 102400 bytes.
2019-07-05 17:37:34.249694: I tensorflow/lite/toco/toco_tooling.cc:397] Estimated count of arithmetic ops: 0.034719 billion (note that a multiply-add is counted as 2 ops).
生成的tflite文件比pb文件还大这正常吗?
-rw-r--r-- 1 ws ws 1393628 7月 5 16:56 frozen_har.pb
-rw-rw-r-- 1 ws ws 1399504 7月 5 17:37 frozen_har.tflite
模型文件的不同格式
GraphDef(.pb),
FrozenGraphDef (.pb with frozen variables),
SavedModel (.pb – used to infer the common format on the server side), and
Checkpoint files (serialized variables during training).
SavedModel
Training Model will generate 3 files representing the network structure. We care about GraphDef and checkpoint files.
-rw-r--r-- 1 ws ws 73 6月 28 16:52 checkpoint
-rw-r--r-- 1 ws ws 800336 6月 28 16:52 har.ckpt.data-00000-of-00001
-rw-r--r-- 1 ws ws 955 6月 28 16:52 har.ckpt.index
-rw-r--r-- 1 ws ws 11945604 6月 28 16:52 har.ckpt.meta
-rw-r--r-- 1 ws ws 16349895 6月 28 16:52 har.pbtxt
此时使用Tensorboard 看到图是training的图
Since we named the input and output layers, we can easily identify them and then begin to understand which layers are necessary for inference and which layers can be discarded.
Again, everything before the input_tensor is not necessary. We need to crop this image before executing it on the mobile device. Most training layers in TFLite are also not supported.
Freeze graph
– this will freeze checkpoint variables in GraphDef
freeze_graph
--input_graph=/tmp/mnist_graph_def_with_ckpts/graph.pbtxt
--input_checkpoint=/tmp/mnist_graph_def_with_ckpts/model.ckpt-48000
-input_binary=false
--output_graph=/tmp/mnist_graph_def_with_ckpts/frozen_mnist.pb
--output_node_names=softmax_tensor
- If you installed TensorFlow with pip, you will get the freeze_graph command. ( installation instructions )
- Open the checkpoint file and determine the latest file. In our case it is model.ckpt-48000
- The Input binary option is false because we are passing a .pbtxt file instead of .pb (in which case it should be true).
- The hardest part is identifying the output_node_name, but since we gave it a name in the training script, it's easy. If you don't provide a training script for the model you're building, you'll need to use Tensorboard and find the automatically generated name for it (I spent a lot of time trying to understand this, so in short, the training script is handy is a huge one.) reward). tf.nn.softmax(logits, name='softmax_tensor'),
Note that freeze_graph actually removes most of the layers used in the training. However, we still have something that is incompatible with TFLite. Specifically, notice the "dropout" and "iterator" layers. These layers are used for training and still need to be cropped (optimize_for_inference当前已经没有这个工具?)
TFLite
The final step is to execute the toco tool and the TensorFlow Lite optimized converter.
也就是上面说的toco工具
TFLite post_training_quantize
/toco --input_file='30_cnn.tflite' --input_format=TFLITE --output_format=TFLITE --output_file='quanized_30_cnn.tflite' --inference_type=FLOAT --input_type=FLOAT --input_arrays=conv1d_input --output_arrays=Identity --input_shapes=1,80,3 --post_training_quantize
Quantization(但依赖saved model dir)
使用底层tensorflow API才能得到SavedModel? keras可以吗?
By reducing the precision of values and operations within a model, quantization can reduce both the size of model and the time required for inference. For many models, there is only a minimal loss of accuracy.
The TensorFlow Lite converter makes it easy to quantize TensorFlow models. The following Python code quantizes a SavedModel
and saves it to disk:
import tensorflow as tfconverter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_quant_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_quantized_model)
使用TOCO工具 --post_training_quantize用于模型压缩
注意要使用源码编译出参考上面的bazel build 自动安装的toco不行
网上给的例子都是pb到tflite 且quantization, 但没有tflite作为输入进行quantization的例子
bazel-bin/tensorflow/lite/toco/toco --input_file='../kerasyolo3/m/transfer_multi_4cl_1207.pb' --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file='../kerasyolo3/m/transfer_multi_4cl_1207.tflite' --inference_type=FLOAT --input_type=FLOAT --input_arrays=input_1 --output_arrays=output_1,output_2,output_3 --input_shapes=1,416,416,3
仔细看toco的help: 这里的输入格式可以是TFLITE
--input_format="TENSORFLOW_GRAPHDEF" string Input file format. One of: TENSORFLOW_GRAPHDEF, TFLITE.
./toco
--input_file='30_cnn.tflite'
--input_format=TFLITE
--output_format=TFLITE
--output_file='quanized_30_cnn.tflite'
--inference_type=FLOAT
--input_type=FLOAT
--input_arrays=conv1d_input
--output_arrays=Identity
--input_shapes=1,80,3
--post_training_quantize
这里关键的是上面几个参数 可以从tflite::PrintInterpreterState(interpreter.get());打印的log看出
Inputs: 1
Outputs: 0
Tensor 0 Identity kTfLiteFloat32 kTfLiteArenaRw 24 bytes ( 0.0 MB) 1 6
Tensor 1 conv1d_input kTfLiteFloat32 kTfLiteArenaRw 960 bytes ( 0.0 MB) 1 80 3
toco执行log
./toco --input_file='30_cnn.tflite' --input_format=TFLITE --output_format=TFLITE --output_file='quanized_30_cnn.tflite' --inference_type=FLOAT --input_type=FLOAT --input_arrays=conv1d_input --output_arrays=Identity --input_shapes=1,80,3 --post_training_quantize
2019-07-11 11:09:30.601131: W tensorflow/lite/toco/toco_cmdline_flags.cc:283] --input_type is deprecated. It was an ambiguous flag that set both --input_data_types and --inference_input_type. If you are trying to complement the input file with information about the type of input arrays, use --input_data_type. If you are trying to control the quantization/dequantization of real-numbers input arrays in the output file, use --inference_input_type.
2019-07-11 11:09:30.603468: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 12 operators, 28 arrays (0 quantized)
2019-07-11 11:09:30.603855: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 12 operators, 28 arrays (0 quantized)
2019-07-11 11:09:30.604693: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 12 operators, 28 arrays (0 quantized)
2019-07-11 11:09:30.605595: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before dequantization graph transformations: 12 operators, 28 arrays (0 quantized)
2019-07-11 11:09:30.606233: I tensorflow/lite/toco/allocate_transient_arrays.cc:345] Total transient array allocated size: 17024 bytes, theoretical optimal value: 16064 bytes.
2019-07-11 11:09:30.606453: I tensorflow/lite/toco/toco_tooling.cc:397] Estimated count of arithmetic ops: 0.00166014 billion (note that a multiply-add is counted as 2 ops).
2019-07-11 11:09:30.607429: I tensorflow/lite/toco/tflite/export.cc:569] Quantizing TFLite model after conversion to flatbuffer. dump_graphviz will only output the model before this transformation. To visualize the output graph use lite/tools/optimize.py.
2019-07-11 11:09:30.612030: I tensorflow/lite/tools/optimize/quantize_weights.cc:199] Skipping quantization of tensor sequential/conv1d/conv1d/ExpandDims_1 because it has fewer than 1024 elements (900).
2019-07-11 11:09:30.612066: I tensorflow/lite/tools/optimize/quantize_weights.cc:278] Quantizing tensor sequential/conv1d_1/conv1d/ExpandDims_1 with 9000 elements for hybrid evaluation.
2019-07-11 11:09:30.612170: I tensorflow/lite/tools/optimize/quantize_weights.cc:278] Quantizing tensor sequential/conv1d_2/conv1d/ExpandDims_1 with 14400 elements for hybrid evaluation.
2019-07-11 11:09:30.612302: I tensorflow/lite/tools/optimize/quantize_weights.cc:278] Quantizing tensor sequential/conv1d_3/conv1d/ExpandDims_1 with 23040 elements for hybrid evaluation.
2019-07-11 11:09:30.612508: I tensorflow/lite/tools/optimize/quantize_weights.cc:199] Skipping quantization of tensor sequential/dense/MatMul/ReadVariableOp/transpose because it has fewer than 1024 elements (288)
按错误提示修改反而crash了
2019-07-11 11:09:30.601131: W tensorflow/lite/toco/toco_cmdline_flags.cc:283] --input_type is deprecated. It was an ambiguous flag that set both --input_data_types and --inference_input_type. If you are trying to complement the input file with information about the type of input arrays, use --input_data_type. If you are trying to control the quantization/dequantization of real-numbers input arrays in the output file, use --inference_input_type.
./toco --input_file='30_cnn.tflite' --input_format=TFLITE --output_format=TFLITE --output_file='quanized_30_cnn.tflite' --inference_input_type=FLOAT --input_data_type=FLOAT --input_arrays=conv1d_input --output_arrays=Identity --input_shapes=1,80,3 --post_training_quantize
2019-07-11 12:05:17.201982: F tensorflow/lite/toco/model_cmdline_flags.cc:289] Check failed: uses_single_input_flags
[1] 25774 abort (core dumped) ./toco --input_file='30_cnn.tflite' --input_format=TFLITE
quantilize前后的文件大小变化过程
-rw-r--r-- 1 ws ws 195212 7月 10 17:55 30_cnn.tflite
-rw-r--r-- 1 ws ws 55872 7月 11 11:09 quanized_30_cnn.tflite
Tensor 0 Identity kTfLiteFloat32 kTfLiteArenaRw 24 bytes ( 0.0 MB) 1 6
Tensor 1 conv1d_input kTfLiteFloat32 kTfLiteArenaRw 960 bytes ( 0.0 MB) 1 80 3
Tensor 2 sequential/conv1d/Relu kTfLiteFloat32 kTfLiteArenaRw 8520 bytes ( 0.0 MB) 1 1 71 30
Tensor 3 sequential/conv1d/conv1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 960 bytes ( 0.0 MB) 1 1 80 3
Tensor 4 sequential/conv1d/conv1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 5 sequential/conv1d/conv1d/ExpandDims_1 kTfLiteFloat32 kTfLiteMmapRo 3600 bytes ( 0.0 MB) 30 1 10 3
Tensor 6 sequential/conv1d/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 120 bytes ( 0.0 MB) 30
Tensor 7 sequential/conv1d_1/conv1d/ExpandDims_1 kTfLiteFloat32 kTfLiteMmapRo 36000 bytes ( 0.0 MB) 30 1 10 30
Tensor 8 sequential/conv1d_1/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 7440 bytes ( 0.0 MB) 1 1 62 30
Tensor 9 sequential/conv1d_1/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 120 bytes ( 0.0 MB) 30
Tensor 10 sequential/conv1d_2/conv1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 2400 bytes ( 0.0 MB) 1 1 20 30
Tensor 11 sequential/conv1d_2/conv1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 12 sequential/conv1d_2/conv1d/ExpandDims_1 kTfLiteFloat32 kTfLiteMmapRo 57600 bytes ( 0.1 MB) 48 1 10 30
Tensor 13 sequential/conv1d_2/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 2112 bytes ( 0.0 MB) 1 1 11 48
Tensor 14 sequential/conv1d_2/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 192 bytes ( 0.0 MB) 48
Tensor 15 sequential/conv1d_3/Relu kTfLiteFloat32 kTfLiteArenaRw 384 bytes ( 0.0 MB) 1 2 48
Tensor 16 sequential/conv1d_3/conv1d/ExpandDims_1 kTfLiteFloat32 kTfLiteMmapRo 92160 bytes ( 0.1 MB) 48 1 10 48
Tensor 17 sequential/conv1d_3/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 384 bytes ( 0.0 MB) 1 1 2 48
Tensor 18 sequential/conv1d_3/conv1d/Squeeze_shape kTfLiteInt32 kTfLiteMmapRo 12 bytes ( 0.0 MB) 3
Tensor 19 sequential/conv1d_3/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 192 bytes ( 0.0 MB) 48
Tensor 20 sequential/dense/BiasAdd kTfLiteFloat32 kTfLiteArenaRw 24 bytes ( 0.0 MB) 1 6
Tensor 21 sequential/dense/MatMul/ReadVariableOp/transpose kTfLiteFloat32 kTfLiteMmapRo 1152 bytes ( 0.0 MB) 6 48
Tensor 22 sequential/dense/MatMul_bias kTfLiteFloat32 kTfLiteMmapRo 24 bytes ( 0.0 MB) 6
Tensor 23 sequential/global_average_pooling1d/Mean kTfLiteFloat32 kTfLiteArenaRw 192 bytes ( 0.0 MB) 1 48
Tensor 24 sequential/global_average_pooling1d/Mean/reduction_indices kTfLiteInt32 kTfLiteMmapRo 4 bytes ( 0.0 MB)
Tensor 25 sequential/max_pooling1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 7440 bytes ( 0.0 MB) 1 62 1 30
Tensor 26 sequential/max_pooling1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 27 sequential/max_pooling1d/MaxPool kTfLiteFloat32 kTfLiteArenaRw 2400 bytes ( 0.0 MB) 1 20 1 30
Tensor 0 Identity kTfLiteFloat32 kTfLiteArenaRw 24 bytes ( 0.0 MB) 1 6
Tensor 1 conv1d_input kTfLiteFloat32 kTfLiteArenaRw 960 bytes ( 0.0 MB) 1 80 3
Tensor 2 sequential/conv1d/Relu kTfLiteFloat32 kTfLiteArenaRw 8520 bytes ( 0.0 MB) 1 1 71 30
Tensor 3 sequential/conv1d/conv1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 960 bytes ( 0.0 MB) 1 1 80 3
Tensor 4 sequential/conv1d/conv1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 5 sequential/conv1d/conv1d/ExpandDims_1 kTfLiteFloat32 kTfLiteMmapRo 3600 bytes ( 0.0 MB) 30 1 10 3
Tensor 6 sequential/conv1d/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 120 bytes ( 0.0 MB) 30
Tensor 7 sequential/conv1d_1/conv1d/ExpandDims_1 kTfLiteUInt8 kTfLiteMmapRo 9000 bytes ( 0.0 MB) 30 1 10 30
Tensor 8 sequential/conv1d_1/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 7440 bytes ( 0.0 MB) 1 1 62 30
Tensor 9 sequential/conv1d_1/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 120 bytes ( 0.0 MB) 30
Tensor 10 sequential/conv1d_2/conv1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 2400 bytes ( 0.0 MB) 1 1 20 30
Tensor 11 sequential/conv1d_2/conv1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 12 sequential/conv1d_2/conv1d/ExpandDims_1 kTfLiteUInt8 kTfLiteMmapRo 14400 bytes ( 0.0 MB) 48 1 10 30
Tensor 13 sequential/conv1d_2/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 2112 bytes ( 0.0 MB) 1 1 11 48
Tensor 14 sequential/conv1d_2/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 192 bytes ( 0.0 MB) 48
Tensor 15 sequential/conv1d_3/Relu kTfLiteFloat32 kTfLiteArenaRw 384 bytes ( 0.0 MB) 1 2 48
Tensor 16 sequential/conv1d_3/conv1d/ExpandDims_1 kTfLiteUInt8 kTfLiteMmapRo 23040 bytes ( 0.0 MB) 48 1 10 48
Tensor 17 sequential/conv1d_3/conv1d/Squeeze kTfLiteFloat32 kTfLiteArenaRw 384 bytes ( 0.0 MB) 1 1 2 48
Tensor 18 sequential/conv1d_3/conv1d/Squeeze_shape kTfLiteInt32 kTfLiteMmapRo 12 bytes ( 0.0 MB) 3
Tensor 19 sequential/conv1d_3/conv1d_bias kTfLiteFloat32 kTfLiteMmapRo 192 bytes ( 0.0 MB) 48
Tensor 20 sequential/dense/BiasAdd kTfLiteFloat32 kTfLiteArenaRw 24 bytes ( 0.0 MB) 1 6
Tensor 21 sequential/dense/MatMul/ReadVariableOp/transpose kTfLiteFloat32 kTfLiteMmapRo 1152 bytes ( 0.0 MB) 6 48
Tensor 22 sequential/dense/MatMul_bias kTfLiteFloat32 kTfLiteMmapRo 24 bytes ( 0.0 MB) 6
Tensor 23 sequential/global_average_pooling1d/Mean kTfLiteFloat32 kTfLiteArenaRw 192 bytes ( 0.0 MB) 1 48
Tensor 24 sequential/global_average_pooling1d/Mean/reduction_indices kTfLiteInt32 kTfLiteMmapRo 4 bytes ( 0.0 MB)
Tensor 25 sequential/max_pooling1d/ExpandDims kTfLiteFloat32 kTfLiteArenaRw 7440 bytes ( 0.0 MB) 1 62 1 30
Tensor 26 sequential/max_pooling1d/ExpandDims/dim_0 kTfLiteInt32 kTfLiteMmapRo 16 bytes ( 0.0 MB) 1 4
Tensor 27 sequential/max_pooling1d/MaxPool kTfLiteFloat32 kTfLiteArenaRw 2400 bytes ( 0.0 MB) 1 20 1 30
这篇关于TfLite: 把pb、h5文件转换为TfLite格式and quantilize的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!