gpt4 book ai didi

python : Cannot retrieve shape of numpy matrix in dict

转载 作者:太空宇宙 更新时间:2023-11-03 17:24:04 25 4
gpt4 key购买 nike

我将 numpy 矩阵存储在字典中。然而,当我尝试找出矩阵的形状时,它失败了:

dict_ = {'one' : np.zeros(shape=(5, 4)), 'two' : np.zeros(shape=(2, 5))}

print type(dict_['one'])
<type 'numpy.ndarray'>

print dict_['one'].shape()
TypeError: 'tuple' object is not callable

我在这里缺少什么?

最佳答案

属性shape不可调用,您需要按如下方式使用它:

print dict_['one'].shape

关于 python : Cannot retrieve shape of numpy matrix in dict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32807274/

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