第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將均勻間隔的值插入 numpy 數(shù)組

將均勻間隔的值插入 numpy 數(shù)組

慕的地6264312 2023-02-12 19:10:58
我正在嘗試重寫以下代碼,processed_feats[0, 0::feats+2] = current_feats[0, 0::feats]processed_feats[0, 1::feats+2] = current_feats[0, 1::feats]processed_feats[0, 2::feats+2] = current_feats[0, 2::feats]processed_feats[0, 3::feats+2] = current_feats[0, 3::feats]processed_feats[0, 4::feats+2] = current_feats[0, 4::feats]processed_feats[0, 5::feats+2] = current_feats[0, 5::feats]processed_feats[0, 6::feats+2] = 0processed_feats[0, 7::feats+2] = 0在哪里feats = 6current_feats is a (1,132) numpy arrayand the size of processed_feats should be (1,176) and have the following format [feat1_1,feat2_1...feat6_1,0,0,feat1_2,feat2_2...]我正在嘗試將它變成一行代碼或更少的代碼行(如果新解決方案的效率低于現(xiàn)有代碼,那么我將回到舊方法)。到目前為止,我已經(jīng)嘗試使用 numpy insertprocessed_feats = np.insert(current_feats,range(6,len(current_feats[0]),feats+2),0)但這并沒有考慮在數(shù)組末尾添加值,我必須使用兩個(gè)插入命令,因?yàn)槲倚枰诿總€(gè) feats+2 索引處添加兩個(gè) 0。
查看完整描述

1 回答

?
尚方寶劍之說

TA貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊

將兩個(gè)數(shù)組重新整形為 22x8 和 22x6,操作簡單地變?yōu)閷⒌诙€(gè)數(shù)組寫入第一個(gè)數(shù)組的前 6 列并將零寫入其他列:


reshaped = processed_feats.reshape((22, 8))

reshaped[:, :6] = current_feats.reshape((22, 6))

reshaped[:, 6:] = 0

reshaped是 的視圖processed_feats,因此將數(shù)據(jù)寫入reshaped到processed_feats。


查看完整回答
反對(duì) 回復(fù) 2023-02-12
  • 1 回答
  • 0 關(guān)注
  • 163 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)