Я пытаюсь внимательно реализовать функцию декодера и получаю сообщение об ошибке:
TypeError: call() missing 1 required positional argument: 'state_c'"
class Decoder(tf.keras.Model):
def __init__(self,out_vocab_size, embedding_dim, output_length, dec_units ,score_fun ,att_units):
#Intialize necessary variables and create an object from the class onestepdecoder
super(Decoder, self).__init__()
self.vocab_size = out_vocab_size
self.embedding_dim = embedding_dim
self.out_length = output_length
self.dec_units = dec_units
self.score_fun = score_fun
self.att_units = att_units
self.stepdec = OneStepDecoder(self.vocab_size, self.embedding_dim,self.out_length, self.dec_units,self.score_fun, self.att_units)
def call(self, input_to_decoder,encoder_output,decoder_hidden_state,state_c ):
all_outputs= tf.TensorArray(tf.float32, size = input_to_decoder.shape[1], name="output_arrays")
for timestep in range(input_to_decoder.shape[1]):
output, input_state = self.stepdec(input_to_decoder[:,timestep:timestep+1],state_c, encoder_output)
all_outputs = all_outputs.write(timestep, output)
all_outputs = tf.transpose(all_outputs.stack(), [1, 0, 2])
return all_outputs
def grader_decoder(score_fun):
out_vocab_size = 13
embedding_dim = 12
input_length = 10
output_length = 11
dec_units = 16
att_units = 16
batch_size = 32
target_sentences = tf.random.uniform(shape=(batch_size,output_length),maxval=10,minval=0,dtype=tf.int32)
encoder_output = tf.random.uniform(shape=[batch_size,input_length,dec_units])
state_h = tf.random.uniform(shape=[batch_size,dec_units])
state_c = tf.random.uniform(shape=[batch_size,dec_units])
decoder = Decoder(out_vocab_size, embedding_dim, output_length, dec_units ,score_fun ,att_units)
output = decoder(target_sentences,encoder_output, state_h, state_c)
assert(output.shape==(batch_size,output_length,out_vocab_size))
return True
print(grader_decoder('dot'))
print(grader_decoder('general'))
print(grader_decoder('concat'))
Мы будем очень признательны за любые предложения или решения.