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

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

TensorFlow 形狀 (?,) 是什么意思?

TensorFlow 形狀 (?,) 是什么意思?

開滿天機 2021-05-30 10:22:28
我得到一個TensofFlow張量的形狀為:(?,)這個答案說的?意思是維在圖中不是固定的,并且在運行調用之間可以變化。?與尾隨的逗號結合是什么意思?文檔章節和詩句將不勝感激。我發現語法非常難以使用Google。
查看完整描述

2 回答

?
慕的地10843

TA貢獻1785條經驗 獲得超8個贊

逗號表示維度表示為1-elem 元組而不是 int。


每個張量在創建時默認為n維:


import tensorflow as tf

t = tf.constant([1, 1, 1])

s = tf.constant([[1, 1, 1],[2,2,2]])


print("0) ", tf.shape(t))

print("1) ", tf.shape(s))


0)  Tensor("Shape_28:0", shape=(1,), dtype=int32)

1)  Tensor("Shape_29:0", shape=(2,), dtype=int32)

但是,您可以重塑形狀以得到更“完整”的形狀(即n X m / n X m X r ...暗):


print("2) ", tf.reshape(t, [3,1]))

print("3) ", tf.reshape(s, [2,3]))


2)  Tensor("Reshape_12:0", shape=(3, 1), dtype=int32)

3)  Tensor("Reshape_13:0", shape=(2, 3), dtype=int32)


查看完整回答
反對 回復 2021-06-01
  • 2 回答
  • 0 關注
  • 286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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