Hi Ptrblck, I really appreciate your analysis. For the latter, yeah, I noticed that it occasionally failed to converge as well. I suspected that it’s due to the random weights. I’m really new, so I wonder if my intuition is wrong here. Thanks again for checking out my code. I spent a lot of time fiddling with version #1 and just could not tell why it wasn’t working after many attempts. I’ll apply the changes you recommended and will report back on the status. Cheers!
edit: also, if my code above is doing anything else that is very wrong/unconventional, I would appreciate it if I could be shown a better way. Thank you in advance.