Naming of caches

The way the cached values are stored ought to be one of the most confusing naming conventions I have ever seen.

One function returns a cache which is then named linear_cache and then used along with activation_cache which is again named cache in another function.

Isn’t there a better way to indicate what cache is supposed to contain what?

This is the first complaint I’ve heard about the naming of the caches in > 4 years, but there has been plenty of confusion about the structure and contents of the caches. For each layer, the cache is a 2-tuple, like this:

((A,W,b), (Z))

So the first element is itself a 3-tuple (the “linear cache”) with contents (A, W, b).

The second element is the activation cache which is a 1-tuple just containing the Z value.

When you finish forward propagation, you end up with an array of those 2-tuple entries with one per “layer” of the network.

(A,W,b) are the inputs to the “linear” calculation of the activation and Z is the input to the activation function, so I think the names make a certain amount of sense.

Thanks for your response. I had understood the structure when I posted that comment. I just thought if naming was done differently it would have been clearer.
A similar choice is made in the return value of an activation function as a tuple, which is fine. Yet, I think a different way of naming these would have made it easier to follow. Chalk that up to my being a picky teacher. Thanks again.

Maybe it is just a failure of imagination on my part, but (as I said in my earlier response) I think the names as given make sense. I would be curious to know what your suggestions are that you think would be more appropriate or make more sense.

And if you need to return more than one value from a function, why is returning a “tuple” not the simplest and clearest way to do that? Note that is a “native python” thing. If you have a function that returns multiple values and you invoke is as:

myReturnVal = myFunction(myInputs)

Then python will automatically create a tuple with all the return values and assign it to myReturnVal.

Oh no returning tuples is one of the coolest Pythonic behaviors. That’s not what I meant.
I just didn’t like the names linear cache (suggesting it might be a linear combination of terms) for the tuple of values would not have been my first choice. I agree the choices made here do make a certain amount of sense. Maybe my first reaction was a bit rushed.

Thanks for your time

1 Like