Reusing someone else's code in my own publication I am about to submit a paper in which one of the algorithms I used is heavily based on the code available on one of the TensowFlow tutorials. In fact, I mostly copied the code from the page and made the necessary modifications for my specific case. I did cite, in the paper, both TensorFlow and the page, and disclosed that the neural net architecture I was using was based on the one on the page. The licensing terms of the code (Apache 2.0) mention that the user is free to build upon the code and redistribute it.

I am not in CS, and am applying the model to a specific problem in my field. However, in copying the code (which I believe will not be disclosed) I am afraid I might be doing academic misconduct. However, on the other hand, if that was the case, using open-source libraries would also be frowned upon, given that the user is essentially copying code.

Will I be committing academic misconduct or anything that is ethically frowned upon in academia by submitting results parts of which were based on copied code?

PS: In response to a comment, I cited TensorFlow and the webpage in the paper, which will be published if accepted, but the code itself (which was heavily based on the code available in the webpage) won't be posted anywhere (as far as I know).
You are doing the right thing as long as you clearly cite your sources. In other words, as long as you say that your code is based on someone else's code, and as long as you clearly cite what that "someone else's code" is and where a reader can find it, you are ok.

The fact that the basis for your work is open source does not require you to share your code as well (though that would clearly be in the spirit of open source software). Open source software generally just means that if you give someone else an executable of your implementation using an open source package, that you also need to give them the source code of your implementation. (The details vary based on the license in question, but that's the idea.) As long as you write the code only for yourself, there is no need or requirement to share it with others.