Somehow the value of w by the time you call from model to optimize to propagate turns out to be a python integer, not a numpy array. So how could that happen? The bug is definitely not in propagate, since it only takes w as an input. But it could either be in optimize or in model or maybe even in your initialize routine. But now you need to track backwards to figure out where that bad value of w came from. Print the type after every place you modify w:
print(f"type(w) = {type(w}")
Actually you can already see one bug in your model code: you are referencing the global variables X and Y when you call optimize. That will not end well, although it’s a bit hard to see how that could cause the “int” error that you show. That would more likely just cause a dimension mismatch error.
Okay. I track it backward there was a little mistake in initialization with zeros. Thank you.
It’s great that you were able to find the solution. Thanks for confirming.