C4W1 UNQ_C6 - Parameters to NMTAttn model?

I know the model prediction (“output”) must be obtained by calling the NMTAttn model with the tuple (input_tokens, padded_with_batch) as parameters, but I can’t understand this as the NMTAttn function is defined with a completely different signature.

Could anyone please explain why this call is correct?

in general, to use your NMTAttn function you would do at first:

model = NMTAttn()

or, if you want to specify some params, something like:

model = NMTAttn(input_vocab_size=24000,
            target_vocab_size=24000,
            d_model=512
            n_encoder_layers=3,
            n_decoder_layers=3)

In this way you have instantiated the model. At this point you would call:

log_probabilities, target_tokens = model( (input1 , input2) )

Now, in exercise 6 of the assignment of week 1, course 4 of NLP, what you write is inside the function:

def next_symbol(NMTAttn, input_tokens, cur_output_tokens, temperature):

and the first parameter of the function NMTAttn is an already instantiated model, it is NOT the NMTAttn function that you wrote in Exercise 4. In some other part of the program it is supposed to happen something like:

my_model =  NMTAttn()
next_symbol(my_model , my_input_tokens, my_cur_output_tokens, my_temperature)

so inside the function “next_symbol” you will get the instantiated model with the name NMTAttn .
Hence it is a model ready to be called passing the two inputs as parameters.

2 Likes