How to properly define a function with changeable parameters within a struct?

Thank you, this definitely works but I have used this approach to define the feed-forward pass of my neural net and I am not sure I can use it to define the NN derivatives as well.