最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

我不明白有兩個(gè)輸入的 map_fn

我不明白有兩個(gè)輸入的 map_fn

偶然的你 2023-12-29 15:39:45
map_fn當(dāng)我在元組上使用它時(shí),我很難理解它的作用。為了測(cè)試我做了以下事情:a = tf.constant([[1,2,3,4],[5,6,7,8],[9,10,11,12]])b = tf.constant([[1,2,3],[4,5,6],[7,8,9]])func = lambda x: x[0]y = tf.map_fn(func,(a,b))我在這里期望的是,map_fn 將 a 和 b 分別分成三個(gè)向量,并將它們賦予 func。func 然后只返回第一個(gè)輸入,而 map_fn 將它們重新堆疊在一起。所以我想我應(yīng)該回來(lái)。相反發(fā)生的是一個(gè)可怕的錯(cuò)誤:ValueError: The two structures don't have the same nested structure.First structure: type=tuple str=(<tf.Tensor: shape=(3, 4), dtype=int32, numpy=array([[ 1,  2,  3,  4],       [ 5,  6,  7,  8],       [ 9, 10, 11, 12]], dtype=int32)>, <tf.Tensor: shape=(3, 3), dtype=int32, numpy=array([[1, 2, 3],       [4, 5, 6],       [7, 8, 9]], dtype=int32)>)Second structure: type=EagerTensor str=tf.Tensor([1 2 3 4], shape=(4,), dtype=int32)More specifically: Substructure "type=tuple str=(<tf.Tensor: shape=(3, 4), dtype=int32, numpy=array([[ 1,  2,  3,  4],       [ 5,  6,  7,  8],       [ 9, 10, 11, 12]], dtype=int32)>, <tf.Tensor: shape=(3, 3), dtype=int32, numpy=array([[1, 2, 3],       [4, 5, 6],       [7, 8, 9]], dtype=int32)>)" is a sequence, while substructure "type=EagerTensor str=tf.Tensor([1 2 3 4], shape=(4,), dtype=int32)" is notDuring handling of the above exception, another exception occurred:ValueError                                Traceback (most recent call last)9 frames/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py in assert_same_structure(nest1, nest2, check_types, expand_composites)    400                   "Entire first structure:\n%s\n"    401                   "Entire second structure:\n%s"--> 402                   % (str(e), str1, str2))    403     404 ValueError: The two structures don't have the same nested structure.First structure: type=tuple str=(<tf.Tensor: shape=(3, 4), dtype=int32, numpy=array([[ 1,  2,  3,  4],       [ 5,  6,  7,  8],       [ 9, 10, 11, 12]], dtype=int32)>, <tf.Tensor: shape=(3, 3), dtype=int32, numpy=array([[1, 2, 3],       [4, 5, 6],       [7, 8, 9]], dtype=int32)>)在我看來(lái),map_fn試圖以某種方式將整個(gè)元組與其組件之一結(jié)合起來(lái)。有人可以解釋一下這是怎么回事嗎?
查看完整描述

1 回答

?
斯蒂芬大帝

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

來(lái)自文檔:

如果 fn 的輸入和輸出簽名不同,則必須使用 fn_output_signature 指定輸出簽名。

您的函數(shù)接受兩個(gè)張量的元組并返回一個(gè)張量,因此您需要指定fn_output_signature

y?=?tf.map_fn(func,(a,b),?fn_output_signature=tf.int32)


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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