gpt4 book ai didi

python - ValueError : Argument must be a dense tensor: [ ['1' , '2' , '3' ], ['1' ]] - 得到形状 [2],但想要 [2, 3]

转载 作者:行者123 更新时间:2023-12-01 01:47:09 25 4
gpt4 key购买 nike

使用 python 3.x tensorflow 版本 1.8.0

代码1:

a2 = [['1', '2'], ['1', '2']]
print(tf.shape(a2))

鳕鱼2:

a2 = [['1', '2', '3'], ['1']] 
print(tf.shape(a2))

cod1 成功,但 code2 错误:

ValueError: Argument must be a dense tensor: [['1', '2', '3'], ['1']] - got shape [2], but wanted [2, 3].

tensorflow var 有平衡吗?为什么code2是错误的?

最佳答案

你不能将不同大小的列表作为张量。

要解决这个问题,请查看 thisthis

关于python - ValueError : Argument must be a dense tensor: [ ['1' , '2' , '3' ], ['1' ]] - 得到形状 [2],但想要 [2, 3],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51184171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com