Я пытаюсь использовать пакет 'keras_self_attention', чтобы применить Self Attention к данным временных рядов. Я хочу использовать слой 'SeqSelfAttention', доступный в пакете. Вот моя модель в функциональном API keras:
_input = keras.layers.Input(shape=(None,), dtype='float32')
expanded_1 = tf.keras.backend.expand_dims(_input,2)
bi = keras.layers.Bidirectional(keras.layers.LSTM(units=128,return_sequences=True))(expanded_1)
attention = SeqSelfAttention(attention_activation='sigmoid')(bi)
expanded_2 = tf.keras.backend.expand_dims(SeqSelfAttention(attention_activation='sigmoid')(bi),2)
output = keras.layers.Dense(units=1,activation='linear')(_input )
model = keras.models.Model(_input,output)
model.compile(optimizer='adam',loss='mse')
При запуске модели я получаю ошибку:
Traceback (most recent call last):
File "data_vs_score.py", line 50, in <module>
model = keras.models.Model(_input,output)
File "/home/varad/.local/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/varad/.local/lib/python3.7/site-packages/keras/engine/network.py", line 94, in __init__
self._init_graph_network(*args, **kwargs)
File "/home/varad/.local/lib/python3.7/site-packages/keras/engine/network.py", line 241, in _init_graph_network
self.inputs, self.outputs)
File "/home/varad/.local/lib/python3.7/site-packages/keras/engine/network.py", line 1434, in _map_graph_network
tensor_index=tensor_index)
File "/home/varad/.local/lib/python3.7/site-packages/keras/engine/network.py", line 1421, in build_map
node_index, tensor_index)
File "/home/varad/.local/lib/python3.7/site-packages/keras/engine/network.py", line 1393, in build_map
node = layer._inbound_nodes[node_index]
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
Это первый раз, когда я спрашиваю вопрос здесь! Поэтому не стесняйтесь говорить мне, если я допустил какую-либо ошибку при формулировании вопроса или вам нужна дополнительная информация. Спасибо!