Входной код: valuelist содержит шесть тензоров, форма которых равна (Нет, 1128), поэтому все значение должно быть (Нет, 6 128), а форма запроса - (Нет, 128).
allvalue = Concatenate(axis=-2,name="concatenatet")(valuelist)
print("allvalue",type(allvalue),allvalue.shape)
val2 = MyAttention.Attention3(name="attalpall")([query,allvalue,allvalue])
Результат печати всего значения:
allvalue <class 'tensorflow.python.framework.ops.Tensor'> (?, 6, 128)
код построения слоя Attention3:
def build(self, input_shape):
print(input_shape)
self.WQ = self.add_weight(name='WQ',
shape=(input_shape[0][-1], input_shape[0][-1]),
initializer='glorot_uniform',
trainable=True)
self.WK = self.add_weight(name='WK',
shape=(input_shape[1][-1], input_shape[1][-1]),
initializer='glorot_uniform',
trainable=True)
self.WV = self.add_weight(name='WV',
shape=(input_shape[2][-1], input_shape[2][-1]),
initializer='glorot_uniform',
trainable=True)
super(Attention3, self).build(input_shape)
Результат печати input_shape:
[(None, 128), None, None]
Итак, я получаю эту ошибку, когда строю свою модель.
shape=(input_shape[1][-1], input_shape[1][-1]),
TypeError: 'NoneType' object is not subscriptable
Кажется, форма запроса правильная, но я не знаю, почему значение all становится None