Both codes look pretty much equal, so it’s weird your model does not output the same values for the same inputs.
Could you post the complete code so that we could have a look at some code bugs or other issues?