【发布时间】:2020-07-25 19:37:00
【问题描述】:
在这里,我尝试进行 one_hot 编码,首先我使用以下代码:
one_hot = one_hot.reshape((array.shape,n_labels))
print(one_hot)
它给了我以下错误: 元组对象不能被解释为整数,然后我看到其他解决方案,代码将是:
one_hot = one_hot.reshape((*array.shape,n_labels))
print(one_hot)
并且问题将得到解决,那么两者之间有什么区别,我的意思是当我使用 (*array.shape,n_labels) 而不是 (array.shape,n_lables) 时会发生什么。我很困惑,找不到它。请帮助我!在此先感谢您。
【问题讨论】:
-
在第二个解压
tuple中,您可以直接访问整数变量。 -
如果你打印(array.shape,n_labels); print(*array.shape,n_labels) 你会看到不同的