Week 2 Exercise 8 - propagate function dimension mismatch

Hey everyone. I encountered a dimension mismatch error in the ‘propagate’ function, but it only occurs when it’s called from the ‘model’ function. The ‘propagate’ function passes all tests when I test it with its test cases. Does anyone know where the problem might be?

{mentor edit: code removed}

Please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

I suspect that somewhere in the chain of function calls, you are either using an incorrect variable name, or are using a global variable where you shouldn’t, or you have reshaped some variable that should have been left alone.

1 Like

As Tom says, the bug is not in propagate. It is in your model logic. You can actually see it in the exception trace you posted: you are passing the wrong argument to the “initialize” routine, so your w value is the wrong shape. It ends up with 7 elements, but it should have 4 in that particular test case.

Once you fix that, your next failure will be that you are not passing all the parameters you need when you call optimize from model.

1 Like