Errors: A Coder’s WORST Nightmare

Chukwurah C -

While I consider myself somewhat competent at coding, I am by no means an expert. This week made that very clear as I encountered errors left and right. Each one led me down a different rabbit hole, but there are still advantages to this. As I continue to dive further into each of these errors, I’ve begun to learn more about the coding principles that govern Python work. So, tedious as it may seem, these errors are fundamental to ensuring I complete the flow field model mentioned in my previous post. In the meantime, let me go into further detail about some of the issues I have encountered.

One of the primary issues that I encountered stemmed from uploading the data(in the format of a .npy file) to be used in PyTorch. I was more familiar with uploading .txt files in Python, so I figured it would be mostly similar. In practice, that was not the case. I ended up having to search online for how to upload the numpy files to PyTorch so I can train and test the model. Rather than relying on the base Python method for accessing downloaded files, Numpy has its own functions to load data. That meant I had to read up on how to achieve this in the most efficient manner possible through sources from primarily Stack Overflow that explained in depth how the .load function works and how it can be implemented in my code.

With that out of the way, I figured the next part in coding the machine learning model would go over more smoothly than the previous. Put simply, I was wrong. I soon ran into an error when I tried to convert the numpy data into a usable form for PyTorch. Since I was working with more than 3 GB of data for each shape, I figured that I should try to split up the data first to test if each section of code worked, instead of waiting an hour only to find out that there was an error towards the end. Fortunately, that helped me catch this error much quicker. The error resulted from trying to make calculations using the wrong data type, since many PyTorch calculations default to using float32 instead of float64, which I had converted the numpy data into. Like most of the errors I’ve encountered with coding, most of the work was finding out where the error was, as opposed to how to fix it.

While I do anticipate encountering further errors in my code, since I am by no means perfect, I am sure that by embracing good coding practices and referring to more experienced coders, I should be able to complete this model satisfactorily. Stay tuned for next week as I push forward and build this drag-based machine learning model!

More Posts

Comments:

All viewpoints are welcome but profane, threatening, disrespectful, or harassing comments will not be tolerated and are subject to moderation up to, and including, full deletion.

    arya_b
    The satisfaction from successfully debugging errors is unparalleled...and they often arise due to the most unrelated problems. Hopefully, you encounter simpler errors (or few errors at all) in the future!
    taksh_b
    I understand the pain you're going through with all these errors (I've been facing them quite a lot in my project, too). Regardless, it's really good to see that you're taking steps to figure out why these errors are happening and working to improve the code!

Leave a Reply

Your email address will not be published. Required fields are marked *