簡體   English   中英

如何為雙向 GRU 獲取序列、隱藏的 state 和單元格 state?

[英]How to get sequence, hidden state and cell state for Bidirectional GRU?

encoder_gru = Bidirectional(GRU(nb_gru_cells,return_sequences=True, return_state=True))
encoder_outputs, encoder_state_fwd_h, encoder_state_fwd_c, encoder_state_bwd_h, encoder_state_bwd_c = encoder_gru1(encoder_inputs)

ValueError:沒有足夠的值來解包(預期 5,得到 3)

為什么只有3個? 它是否在內部連接了前向和后向狀態? 那么它是輸出、fwd_h、bwd_h 還是輸出、隱藏狀態、單元狀態?

LSTM 在 output(輸出、隱藏和單元)處具有三個值,而 GRU 在 output(輸出和隱藏)處具有兩個值。 GRU 中沒有單元格 state 因此應該從您的代碼中刪除前向和后向單元格狀態。

encoder_gru = 雙向(GRU(nb_gru_cells,return_sequences=True, return_state=True)) 編碼器輸出,encoder_state_fwd_h,encoder_state_fwd_c = encoder_gru1(encoder_inputs)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM