DLS Course 5 Week 3 Assignment 1: Missing argument "m" in "modelf"

I have completed this assignment “Neural_machine_translation_with_attention_v4a”, but I would like to share my observation about a very confusing design of function “modelf”, which needs “m” (batch size) as another argument, which is currently missing:

def modelf(Tx, Ty, n_a, n_s, human_vocab_size, machine_vocab_size):

In fact, its unit test defines “m”, but does not pass it to “modelf” explicitly, an the latter is supposed to use “m” as defined locally in “modelf_test”. This is not only poor design, but also very confusing in this case.

from test_utils import *

def modelf_test(target):
m = 10
Tx = 30
n_a = 32
n_s = 64
len_human_vocab = 37
len_machine_vocab = 11
model = target(Tx, Ty, n_a, n_s, len_human_vocab, len_machine_vocab)

Without “m”, nothing worked for me. I spent a lot of time to figure out that I need “m”. If mentors want to elaborate on this issue, they are welcome.

That does look a little odd.
I’ll check into it further.

I commented out the “m = 10” line, restarted the kernel and cleared the output, then ran all the cells, and it seems to have worked normally.

I did not yet try submitting it for a grade.

Did you perhaps use a global variable ‘m’ into one of the other functions?

Hi @TMosh ! Obviously, I do not know which code you added before you ran the assignment. The original code of the function “modelf” does not use “m”. However, after I added my code to it, I had to use “m”, or else the unit tests failed. I am not sure what you mean by “worked normally” without “m”. Did all your unit tests succeed without “m”, including Exercises 2 and 3? Or did you actually use “m” inside “modelf”? Clearly, I cannot disclose my solution here. But I will give you a hint: in Exercise 2, we need to use “m” similarly with the way it is used in the Unit tests of Exercise 1 of the same Assignment “Neural_machine_translation_with_attention_v4a”.

I do not think that is true.

The change I made to my notebook was this:

After that I was still able to run all of the cells in the notebook without error.

I have submitted an issue ticket to the course authors to remove the “m = 10” statement from the modelf_test() function, because it isn’t used or needed.