现在不是都用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

  1. If you installed TensorFlow with pip, you will get the freeze_graph command. ( installation instructions )
  2. Open the checkpoint file and determine the latest file. In our case it is model.ckpt-48000
  3. The Input binary option is false because we are passing a .pbtxt file instead of .pb (in which case it should be true).
  4. 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相关推荐

  1. linux中一条命令将文件转换为UTF-8格式-解决乱码

    需要apt安装enca enca -L zh_CN -x UTF-8 * && dos2unix * 作用:将当前目录所有文件转换为utf-8格式,并将windows换行转换为unix ...

  2. C# 将PDF文件转换为word格式

    Pdf(Portable Document Format)意为"便携式文档格式",是现在最流行的文件格式之一,它有很多优点如:尺寸较小.阅读方便.操作系统平台通用等,非常适合在网络 ...

  3. 怎样快速的将WPS文件转换为word格式

    如何将WPS文件转换为word格式!相信大家会很有疑问的,由于一般在工作中在办公使用的WPS所以保存的文件都是以WPS格式的文件,那么有时候可能需要你将WPS转换成word格式.那么下面小编交给大家一 ...

  4. 快速转换:将音乐文件转换为MP3格式的步骤

    如果你有一个音乐文件,但它的格式不是MP3,你可能需要将其转换为MP3格式,这样它就可以被更广泛地播放和共享.下面是一些步骤,帮助你快速将音乐文件转换为MP3格式. 1.下载并安装一个音频转换软件.有 ...

  5. 利用ArcGIS软件将csv文件转换为shp格式

    对所有的HDF5文件提取自己所需要的信息之后,每一个csv文件都可以在ArcGIS中进行展点显示,但是我们所需要的不只是单个csv文件进行展点显示,我们需要将所有的csv文件进行展点显示以方便之后进行 ...

  6. 将VOC格式标注文件转换为Yolo格式

    这篇文章主要参考博客中的代码,对原博客VOC格式数据集转yolo格式代码进行一定修改.添加注释,此外还在后面添加了我自己写的一段关于对转换后的图片和标注文件进行整理的脚本代码. 关于数据集在Yolo格 ...

  7. msg文件转成html文件,如何将MSG格式的文件转换为PDF格式文件?

    三.如何将MSG格式的文件转换为PDF格式的文件? 想要随时查看MSG格式文件的话,格式转换就成为了理想的途径,下面将教大家将MSG格式的文件转换为PDF格式文件三种方式,一起去学习一下吧. 1.借助 ...

  8. 如何在 Linux 中使用 Calibre 将 PDF 文件转换为 EPUB 格式?

    在这个现代时代,一切都被数字化了,电子书已成为主流,电子书有多种格式,如 PDF.EPUB.MOBI.AZW3 和 IBA 等. 大多数电子书阅读器支持几乎所有格式,但是,某些电子书阅读器可能不支持特 ...

  9. 用 python 脚本,把当前目录及子目录下的 wav 音频文件转换为 flac 格式

    用 python 脚本,把当前目录及子目录下的 wav 音频文件转换为 flac 格式 import os, subprocessfor d,sd,files in os.walk('.'):for ...

最新文章

  1. Eclipse error: “The import XXX cannot be resolved”
  2. [PAMI2013] Guided Image Filtering 导向滤波器以及OpenCV-Python代码实现
  3. mysql8.0.11 安装顺序_mysql 8.0.11 安装步骤详解
  4. 敏捷项目管理过程改进
  5. ROS中阶笔记(五):机器人感知—机器视觉
  6. 自定义---单批次训练函数
  7. 广东第一高中生_曝前广东第一高中生将加盟广东,他或成宏远最有希望之人
  8. php小程序 b支付回调视频教程,Laravel教程: 3分钟实现小程序微信支付接入(下)——回调发货逻辑...
  9. Keil5二步解决中文乱码,注释乱码问题
  10. [转]用python来开发webgame服务端(5)
  11. VTP(VLAN中继协议)简单介绍
  12. python 以图搜图_以图搜图系统概述
  13. 人工智能时代党政人力资源的思考与变化
  14. 机器学习之logistic 回归
  15. the system can not open the device or file specified解决方案
  16. 如果将网页素材转为html,html/css
  17. 微信APP支付申请配置流程
  18. Git for Windows 国内下载站,免翻快速下载安装
  19. 这是一趟豪华的 Android 列车,就问你上不上?
  20. 【180927】华容道游戏源码

热门文章

  1. [BZOJ2844]albus就是要第一个出场(线性基)
  2. 范特西视频 v1.3.8
  3. 从零编写60%+胜率的短线择时信号!零基础python量化投资代码详解【邢不行】
  4. Android Wear开发浅析(一)
  5. python画图颜色随机_用python画随机颜色随机大小随机位置的正方形
  6. RADIUS协议 [收藏]
  7. 一千万条数据去重_DB2千万级数据去重
  8. Web前端开发的思考与经验----五年工作经验
  9. Linux系统中more和less命令的区别
  10. 货币政策和财政政策区分