3 回答

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊
numpy.tile
np.tile(my_input_array,?3)
輸出
array([-1.02295637,?-0.60583836,?-0.42240581,?-0.78376377,?-0.85821456, ???????-1.02295637,?-0.60583836,?-0.42240581,?-0.78376377,?-0.85821456, ???????-1.02295637,?-0.60583836,?-0.42240581,?-0.78376377,?-0.85821456])
編輯:剛剛注意到@hpaulj 的回答。我仍然會(huì)留下我的答案,但他首先提到了 np.tile。

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊
只需使用將tile
數(shù)組與給定形狀相乘的方法和reshape
方法來(lái)構(gòu)造它。用于x.shape[0]*x.shape[1]
將其更改為列向量,而無(wú)需明確給出形狀尺寸!
x=np.tile(x,(3,1)) y=x.reshape(x.shape[0]*x.shape[1])

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超5個(gè)贊
這就是你想要的:
x=np.concatenate([my_input_array, my_input_array, my_input_array])
for i in x:
print(i)
輸出:
-1.02295637
-0.60583836
-0.42240581
-0.78376377
-0.85821456
-1.02295637
-0.60583836
-0.42240581
-0.78376377
-0.85821456
-1.02295637
-0.60583836
-0.42240581
-0.78376377
-0.85821456
添加回答
舉報(bào)