'builtin_function_or_method'对象没有属性'reshape' - 我无法解决这个问题[关闭]

问题描述 投票:0回答:1
length = len(test_set)
array = np.array
target = array.reshape([1, seq_length, data_dim])

out = model(target)
pre = torch.flatten(out).item()

我收到了这个错误


   155 length = len(test_set)
    156 array = np.array
--> 157 target = array.reshape([1, seq_length, data_dim])
    159 out = model(target)
    160 pre = torch.flatten(out).item()

AttributeError: 'builtin_function_or_method' object has no attribute 'reshape'

我知道 np.array 和 reshape 不能一起使用 但我不知道如何更改代码

python reshape
1个回答
0
投票

你还没有真正创建一个数组;

np.array
只是绑定了一个名为
array
的新名称。创建一个实际上包含某些内容的数组。

© www.soinside.com 2019 - 2024. All rights reserved.