亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Tensorflow:如何以保持 2D 張量形狀的方式使用 boolean_mask

Tensorflow:如何以保持 2D 張量形狀的方式使用 boolean_mask

守候你守候我 2021-09-28 15:47:16
當我使用 tf.boolean_mask 時,結果是扁平化的。tensor7 = tf.constant( [[ 0,  1,  2,  3, -1],[ 2,  3,  4, -1, -1],[ 3,  6,  5,  4,  3]], tf.int64)mask7 = tf.constant([[ True,  True,  True,  True, False],  [ True,  True,  True, False, False], [ True,  True,  True,  True,  True]], tf.bool)result7=tf.boolean_mask(tensor7, mask7, axis=0)  with tf.Session() as sess:    print(sess.run([ result7 ]))數組([0, 1, 2, 3, 2, 3, 4, 3, 6, 5, 4, 3])]有沒有辦法使用它來保留原始的 3 數組形狀?各個陣列的形狀應該改變,因為它們現在更短了。我正在尋找這樣的東西[數組([[ 0, 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 6, 5, 4, 3]])
查看完整描述

1 回答

?
白豬掌柜的

TA貢獻1893條經驗 獲得超10個贊

您的期望在邏輯上可能不合理,正如與您的問題類似的功能請求中進一步指出的那樣。您需要為張量提供動態形狀,這在 TensorFlow 中只有有限的支持(例如Ragged Tensors)。


查看完整回答
反對 回復 2021-09-28
  • 1 回答
  • 0 關注
  • 184 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號