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

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

Keras 中的串聯層

Keras 中的串聯層

PHP
千萬里不及你 2023-11-09 15:52:15
我正在嘗試接受 2 個輸入到我的模型中。但它有一個奇怪的問題。x1= layers.Input((20000,))x2= layers.Reshape((200,100), input_shape=(20000,))(x1)y1= layers.Input((200000,))y2= layers.Reshape((2000,100), input_shape=(200000,))(y1)combine = layers.Concatenate(axis=1)([x2, y2])model = tf.keras.Model(inputs=[x1, y1], outputs=combine)model.predict([datasetA, datasetB])如果我接受一個輸入,模型就可以運行。model = tf.keras.Model(inputs=[x1], output=x2)model.predict(datasetA)但如果我接受兩個輸入,模型就死了。Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'tensorflow.python.data.ops.dataset_ops.PrefetchDataset'>"}), <class 'NoneType'>即我的數據集的結構是:<PrefetchDataset shapes: ((None, 20000), (None,)), types: (tf.int64, tf.int32)>1 Dataset -> 5 Batche_data and 5 batch_LabelEach Batch_data -> 3 recordsEach record -> [20000]Each batch_Label -> 3 recordsEach label -> 0 / 1 for classification我該如何解決這個問題?
查看完整描述

2 回答

?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

好的,所以我找到了答案,一切都很簡單。在自然狀態下,它僅返回 140 個字符,因此而不是

statuses = api.user_timeline(id=462886126)    print(statuses[0].text)

我只需要:

statuses = api.user_timeline(id=462886126, tweet_mode='extended')    print(statuses[2].full_text)


查看完整回答
反對 回復 2023-11-09
?
慕哥9229398

TA貢獻1877條經驗 獲得超6個贊

您用于tensoflow.keras導入圖層嗎?唯一可能出現model.summary 問題的是您通過模型的形狀。


這段代碼工作正常。張量流==2.0.0


import tensorflow as tf

import numpy as np


datasetA = np.zeros((10,20000),dtype=int)

datasetB = np.zeros((10,200000),dtype=int)


x1= tf.keras.layers.Input((20000,))

x2= tf.keras.layers.Reshape((200,100), input_shape=(20000,))(x1)


y1= tf.keras.layers.Input((200000,))

y2= tf.keras.layers.Reshape((2000,100), input_shape=(200000,))(y1)


combine = tf.keras.layers.Concatenate(axis=1)([x2, y2])

model = tf.keras.Model(inputs=[x1, y1], outputs=combine)

model.summary()

model.predict([datasetA, datasetB])

print('the predict done')], outputs=combine)


查看完整回答
反對 回復 2023-11-09
  • 2 回答
  • 0 關注
  • 146 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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