mlmodel的输出形状为空.为什么形状为空?

编程入门 行业动态 更新时间:2024-10-10 21:24:43
本文介绍了mlmodel的输出形状为空.为什么形状为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我研究了本教程 www.tensorflow/tutorials/generative/cyclegan,并且在Windows上可以很好地完成模型.然后,我将此tf模型转换为mlmodel,但是模型的输出(MultyArray)的形状为空.我该如何解决这个问题...?(此型号的EPOCH为1)

I study this tutorial www.tensorflow/tutorials/generative/cyclegan and the completed model is well worked on windows. Then I convert this tf model to mlmodel, but the model's output(MultyArray) has empty shape. How do i solve this problem...? (This model's EPOCH is 1)

计算机::: Windows10/Tensorflow和-gpu 2.2/tfcoreml 1.1

computer::: windows10 / tensorflow and -gpu 2.2 / tfcoreml 1.1

这是转换代码

import tfcoreml import coremltools from tensorflow import keras saved_model = keras.models.load_model('saved_model') # get input, output node names for the TF graph from the Keras model input_name = (saved_model.inputs[0].name.split(':')[0])[0:7] keras_output_node_name = saved_model.outputs[0].name.split(':')[0] graph_output_node_name = keras_output_node_name.split('/')[-1] # Saving the Core ML model to a file. model = tfcoreml.convert('saved_model', image_input_names=input_name, input_name_shape_dict={input_name: [1, 540, 540, 3]}, output_feature_names=[graph_output_node_name], minimum_ios_deployment_target='13', red_bias=-123.68, green_bias=-116.78, blue_bias=-103.94) model.save('./saved_mlmodel/saved_model.mlmodel')

这是save_model.summary

this is saved_model.summary

Model: "model_1" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_2 (InputLayer) [(None, None, None, 0 __________________________________________________________________________________________________ sequential_15 (Sequential) (None, None, None, 6 3072 input_2[0][0] __________________________________________________________________________________________________ sequential_16 (Sequential) (None, None, None, 1 131328 sequential_15[0][0] __________________________________________________________________________________________________ sequential_17 (Sequential) (None, None, None, 2 524800 sequential_16[0][0] __________________________________________________________________________________________________ sequential_18 (Sequential) (None, None, None, 5 2098176 sequential_17[0][0] __________________________________________________________________________________________________ sequential_19 (Sequential) (None, None, None, 5 4195328 sequential_18[0][0] __________________________________________________________________________________________________ sequential_20 (Sequential) (None, None, None, 5 4195328 sequential_19[0][0] __________________________________________________________________________________________________ sequential_21 (Sequential) (None, None, None, 5 4195328 sequential_20[0][0] __________________________________________________________________________________________________ sequential_22 (Sequential) (None, None, None, 5 4195328 sequential_21[0][0] __________________________________________________________________________________________________ sequential_23 (Sequential) (None, None, None, 5 4195328 sequential_22[0][0] __________________________________________________________________________________________________ concatenate_1 (Concatenate) multiple 0 sequential_23[0][0] sequential_21[0][0] sequential_24[0][0] sequential_20[0][0] sequential_25[0][0] sequential_19[0][0] sequential_26[0][0] sequential_18[0][0] sequential_27[0][0] sequential_17[0][0] sequential_28[0][0] sequential_16[0][0] sequential_29[0][0] sequential_15[0][0] __________________________________________________________________________________________________ sequential_24 (Sequential) (None, None, None, 5 8389632 concatenate_1[0][0] __________________________________________________________________________________________________ sequential_25 (Sequential) (None, None, None, 5 8389632 concatenate_1[1][0] __________________________________________________________________________________________________ sequential_26 (Sequential) (None, None, None, 5 8389632 concatenate_1[2][0] __________________________________________________________________________________________________ sequential_27 (Sequential) (None, None, None, 2 4194816 concatenate_1[3][0] __________________________________________________________________________________________________ sequential_28 (Sequential) (None, None, None, 1 1048832 concatenate_1[4][0] __________________________________________________________________________________________________ sequential_29 (Sequential) (None, None, None, 6 262272 concatenate_1[5][0] __________________________________________________________________________________________________ conv2d_transpose_15 (Conv2DTran (None, None, None, 3 6147 concatenate_1[6][0] ================================================================================================== Total params: 54,414,979 Trainable params: 54,414,979 Non-trainable params: 0

这是mlmodel.spec说明

this is mlmodel.spec description

input { name: "input_2" type { imageType { width: 540 height: 540 colorSpace: RGB } } } output { name: "Identity" type { multiArrayType { dataType: FLOAT32 } } } metadata { userDefined { key: "coremltoolsVersion" value: "3.4" } }

推荐答案

这通常不是问题.当你运行模型时,你仍然会得到一个正确形状的多数组.

This is usually not a problem. When you run the model, you still get a multi-array of the correct shape.

如果您已经知道形状,则可以对其进行填充,以使其显示在mlmodel文件中,但这更多是出于文档目的.

If you already know the shape, you can fill it in so that it shows up in the mlmodel file, but this is more for documentation purposes than anything else.

更多推荐

mlmodel的输出形状为空.为什么形状为空?

本文发布于:2023-10-27 23:59:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534909.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   形状   mlmodel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!