A new list is created once when the function is defined, and the same list is used in each successive call.
Python’s default arguments are evaluated once when the function is defined, not each time the function is called (like it is in say, Ruby). This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well.
If this is the functionality you want (i.e continual adding elements into that initial list) then that's fine, we can leave it as is.
But if you want the list to be redefined everytime the function is called, I would suggest changing it to this:
In function
conv_layer
the parameterstride
on this line has a mutable default argument[1, 1, 1, 1]
. Is this intentional?This article explains why this is a problem with the following example:
If this is the functionality you want (i.e continual adding elements into that initial list) then that's fine, we can leave it as is.
But if you want the list to be redefined everytime the function is called, I would suggest changing it to this: