Numpy 无法重塑

Numpy 无法重塑,numpy,ipython,jupyter-notebook,Numpy,Ipython,Jupyter Notebook,当我运行以下代码时,您好: for record in training_data_list: all_values = record.split(',') y_inputs = (np.asfarray(all_values[0])) ab = np.zeros(10) ab[int(all_values[0])] = 1 print("ab= " + str(ab)) print("shape

当我运行以下代码时,您好:

for record in training_data_list:
        all_values = record.split(',')
        y_inputs = (np.asfarray(all_values[0]))

        ab = np.zeros(10)
        ab[int(all_values[0])] = 1

        print("ab= " + str(ab))
        print("shape ab= " + str(ab.shape))
        ac = np.expand_dims(ab, axis=0).T
        print("ac = " + str(ac))
        print("shape AC = " + str(ac.shape))
        ac = ac.reshape((10,Y.shape[1]))
        print("shape ac = " + str(ac.shape))
我遇到了以下错误:

ValueError: cannot reshape array of size 10 into shape (10,103)
“重塑”命令之前ac的形状为(10,1) Y的形状=(1103)

所以我想要ac(10103)的as形状


第二个问题,为什么错误告诉我当大小为(10,1)时不能重塑大小为10的数组?

形状可能是(10,1),但大小是10-10个元素<代码>重塑只能更改
形状
,而不更改
大小
。(10103)的
大小为1030!我想你想用
重复
。你好,你能告诉我如何得到(10103)的形状吗?最终使用repeat命令?
np.repeat(x,103,axis=1)