ValueError: The two structures don't have the same sequence length. Input structure has length 4, while shallow structure has length 3.

ValueError: The two structures don't have the same sequence length. Input structure has length 4, while shallow structure has length 3.

整体报错:

/opt/conda/lib/python3.6/site-packages/tensorflow/python/util/nest.py:1460 map_structure_with_tuple_paths_up_to
expand_composites=expand_composites)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/util/nest.py:1091 assert_shallow_structure
input_length=len(input_tree), shallow_length=len(shallow_tree)))
ValueError: The two structures don't have the same sequence length. Input structure has length 4, while shallow structure has length 3.

参考资料

ValueError: The two structures don‘t have the same sequence length._input structure has length 2, while shallow struct_qq_34292087的博客-CSDN博客

ValueError: The two structures don't have the same sequence length. Input structure has length 0, while shallow structure has length 9. · Issue #17 · FurkanOM/tf-faster-rcnn · GitHub

https://stackoverflow.com/questions/71350360/valueerror-the-two-structures-dont-have-the-same-sequence-length-input-struct

解决

问题主要是两组结构的序列长度不同,这里需要检查一下所使用的特征以及模型结构的输入输出维度是否发生变化。

在我这个代码当中,主要是模型的输出头的个数发生了变化,在dataset当中配置了4个label输出,实际模型错误地写成了3个输出头。

比如

task_output = [task_ouput_1, task_output_2, task_output_3]
train_model = tf.keras.models.Model(inputs=get_keras_model_input(inputs, task_outputs)

修改成

task_output = [task_ouput_1, task_output_2, task_output_3, task_output_4]
train_model = tf.keras.models.Model(inputs=get_keras_model_input(inputs, task_outputs)
posted @   NoMornings  阅读(137)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示