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

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

ONNX.js 中的 Pytorch LSTM - 未捕獲(承諾中)錯(cuò)誤:無(wú)法識(shí)別節(jié)點(diǎn)的輸入“”:

ONNX.js 中的 Pytorch LSTM - 未捕獲(承諾中)錯(cuò)誤:無(wú)法識(shí)別節(jié)點(diǎn)的輸入“”:

慕慕森 2023-12-14 14:11:20
我正在嘗試在瀏覽器中運(yùn)行 Pytorch LSTM 網(wǎng)絡(luò)。但我收到此錯(cuò)誤:graph.ts:313 Uncaught (in promise) Error: unrecognized input '' for node: LSTM_4    at t.buildGraph (graph.ts:313)    at new t (graph.ts:139)    at Object.from (graph.ts:77)    at t.load (model.ts:25)    at session.ts:85    at t.event (instrument.ts:294)    at e.initialize (session.ts:81)    at e.<anonymous> (session.ts:63)    at onnx.min.js:14    at Object.next (onnx.min.js:14)我該如何解決這個(gè)問(wèn)題?這是我將模型保存到 onnx 的代碼:net = torch.load('trained_model/trained_model.pt')net.eval()with torch.no_grad():    input = torch.tensor([[1,2,3,4,5,6,7,8,9]])    h0, c0 = net.init_hidden(1)    output, (hn, cn) = net.forward(input, (h0,c0))    torch.onnx.export(net, (input, (h0, c0)), 'trained_model/trained_model.onnx',                    input_names=['input', 'h0', 'c0'],                    output_names=['output', 'hn', 'cn'],                    dynamic_axes={'input': {0: 'sequence'}})我將輸入作為唯一的動(dòng)態(tài)軸,因?yàn)樗俏ㄒ豢梢愿淖兇笮〉妮S。使用此代碼,模型可以正確保存為trained_model.onnx。它確實(shí)給了我一個(gè)警告:UserWarning: Exporting a model to ONNX with a batch_size other than 1, with a variable length with LSTM can cause an error when running the ONNX model with a different batch size. Make sure to save the model with a batch size of 1, or define the initial states (h0/c0) as inputs of the model.   warnings.warn("Exporting a model to ONNX with a batch_size other than 1, "這個(gè)警告有點(diǎn)令人困惑,因?yàn)槲沂褂门看笮?1 導(dǎo)出它:輸入的形狀為 torch.Size([1, 9])h0 的形狀為 torch.Size([2, 1, 256]) - 對(duì)應(yīng)于 (num_lstm_layers, batch_size, hide_dim)c0 也有形狀 torch.Size([2, 1, 256])但由于我確實(shí)將 h0/c0 定義為模型的輸入,所以我認(rèn)為這與問(wèn)題無(wú)關(guān)。根據(jù) console.log 語(yǔ)句,無(wú)法加載到模型。我應(yīng)該如何解決這個(gè)問(wèn)題?如果相關(guān)的話我正在使用Python 3.8.5、Pytorch 1.6.0、ONNX 1.8.0。
查看完整描述

1 回答

?
鳳凰求蠱

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

對(duì)于將來(lái)遇到此問(wèn)題的任何人,我相信我會(huì)收到此錯(cuò)誤,因?yàn)榧词?ONNX 支持 Pytorch LSTM 網(wǎng)絡(luò),ONNX.js 尚不支持它。

為了解決這個(gè)問(wèn)題,我可以使用一個(gè)名為Streamlit的簡(jiǎn)單 Web 應(yīng)用程序框架,而不是在瀏覽器中運(yùn)行。


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

添加回答

舉報(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)