Failing to implement my first paper

For the past week, I’ve been implementing a paper that creates labels on seismic images. This was done so I would implement another paper from the same authors that would make a convolutional network learn features from those labels. But I was not able to do so. I will be explaining why in the blog post.

In the beginning I found this paper which used weak labels to learn features of the images. But from reading the paper. I had to make the labels myself. So, I checked another paper they referenced which they made the labels. In that paper they made pixel-level labels from the general image labels. They had papers which featured their algorithm. One here, included a summary of the algorithm. Which is the first paper I found. And here is a second one which is more detailed. Which is the one I later used to help code the project.

Before I started coding the machine learning model to generate the labels. I did data exploration. The dataset I got was called LANDMASS. From the authors of the paper. It has thousands seismic images of the Netherlands North Sea. As that was a lot of data, I first looked at 10 images. I first had to convert the images from MATLAB file to a normal image. Which proved difficult in the beginning. But later got the hang of it, with the help of this medium article. And this formula, from stack overflow to convert the normalised data into normal pixels.

round((img + 1) * 255 / 2)

Figure 1 Chaotic Image

Figure 1 Chaotic Image

After I was able to get an idea of what the images look like. I started work on the machine learning model. To get the data needed for the model. I need to collect all of the images from the different categories. Which include chaotic, horizon, fault, and salt dome. Again, as the dataset included thousands of images. I chose 10 images per category. After I collected all the images. I used a K-means algorithm to initialise the feature matrix.

But later on, I missed one crucial factor, that the paper mentioned. The images were turned into vectors. So, I found a piece of code that turn images into vectors. I collected the images in vector in this time. The major algorithm used was Non-negative matrix factorization. But my computer did not have the packages required to do so.(At the time was going to use TensorFlow). So, I moved to Google Colab. Even though I did not use TensorFlow to make the NMF model. Using google colab was better as I was able to use google servers to compute my model. I used Scikit-learn NMF module instead. After that I made the labels after the model converged. After that I had use an argmax function on the columns. Then apply a median filter to get rid of noisy labels.

Then I plotted the labels. Then this is where the main problem arises. After I plotted the labels, they looked something like this:

image003.png

This looked nothing like the labels were supposed to look. Here is the example from the research paper:

image005.png

I reshaped the data numerous times and ways. And edited the NMF model. But not too much success. I don’t know how to move forward. As fixing the problem is not to clear. And have been googling around to find an answer. I also used slicing of the label data. So, it will be the same length an image in the dataset. But did not make the label much clearer.

After that I tried plot the images saved in the arrays. I eventually got it to work by using slicing. By slicing it like this [:256, 256]. Means 256 pixels rows and columns will be plotted. But one minor thing is that when using matplotlib image plotting unlike Pillow shows a type of blueish colour.

image007.png

One of the solutions I tried was adding more data. So, added more 40 images per category. 50 images will be saved in each category. But did not change much. One solution I have not used is creating the NMF model from scratch. Basically, not using Scikit learn for NMF. And use something like TensorFlow. As the paper has their own NMF equation which uses a sparsity measure. To make up for the fact the label will be weak.

image009.png
image011.png
image013.png

And I could also try to use a more custom k-means algorithm. But the paper does not add any detail for a custom k-means algorithm. So standard k-means algorithm may not be the issue.

Having the models more custom made may be the answer. As I think the main issue which is causing the problems is the shape of the data. Having a more custom model will show me how the data is being manipulated. Only problem is making the custom model is hard. And I need to translate the maths to code. One of the hardest bits when coding up the project was working out the Q variable.

image015.png

And I still don’t know if I did that correctly. Especially for the hn variable which I had remove from the equation because I did not know what operator to add or how to define it in the equation. So even if did the custom model and reworked the Q value. Just due to the lack of knowledge translating the maths into code. Still may not be possible.

So, this is my first serious attempt of implementing a paper. I think its fine to say that I did not succeed. But I’ve learnt lots of new stuff. Like better knowledge of maths notation. And furthering my use of scikit learn. I will be trying to implement other papers soon.

Updated:

I copied a TensorFlow Implemented of NMF. Not much different. Trying to implement the papers multiplicative update rules is proving very difficult. As I’m struggling to understand the notation.  Highlighted the problems that I’m struggling to read.

image019.png

 

Tobi Olabode