{"id":7515,"date":"2021-08-03T08:45:03","date_gmt":"2021-08-03T12:45:03","guid":{"rendered":"https:\/\/blogs.mathworks.com\/deep-learning\/?p=7515"},"modified":"2021-08-03T08:45:03","modified_gmt":"2021-08-03T12:45:03","slug":"mathworks-wins-geoscience-ai-gpu-hackathon","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/deep-learning\/2021\/08\/03\/mathworks-wins-geoscience-ai-gpu-hackathon\/","title":{"rendered":"MathWorks Wins Geoscience AI GPU Hackathon"},"content":{"rendered":"<em>The following post is from Akhilesh Mishra, Mil Shastri and Samvith V. Rao from MathWorks here to talk about their participation and in a Geoscience hackathon. Akhilesh and Mil are Applications Engineers and Samvith is the Industry Marketing Manager supporting the Oil and Gas industry. <\/em>\r\n<h6><\/h6>\r\n<h2>Background<\/h2>\r\nSEAM (SEG Advanced Modeling Corp.) is a petroleum geoscience industry body that fosters\u00a0collaborations among industry, government, and academia to address major Geological challenges. Their latest event was a hackathon (<a href=\"https:\/\/www.gpuhackathons.org\/event\/seam-ai-applied-geoscience-gpu-hackathon\">SEAM AI Applied Geoscience GPU Hackathon<\/a>) that sought to\u00a0explore the use of AI to improve both qualitative and quantitative interpretation of geophysical images of Earth's interior, and speed up the applications using NVIDIA GPUs.\r\n<h6><\/h6>\r\nA total of 7 teams participated from all over the world, including commercial companies (Chevron, Total, Petrobras) and a mix of industry and university students. Each team was assigned a mentor who is an expert geoscientist working for a top oil and gas company.\r\n<h6><\/h6>\r\n<h2>The Challenge<\/h2>\r\n<h6><\/h6>\r\nGeologic interpretation of survey data\u2014especially raw seismic images of Earth's interior is an important step for the oil and gas industry.\u00a0Seismic images delineate volumes of rock inside the Earth with different physical and geologic characteristics summarized by the term <strong>\u201cfacies\u201d.<\/strong> An important step in interpretation of the images\u2014which guide exploration, drilling, production, and abandonment of underground reservoirs\u2014is identification and classification of all distinct geologic facies in a seismic image, often called <em>seismic facies identification or classification<\/em>.\r\n<h6><\/h6>\r\nThis process is still done largely geologists assisted by specialists in geophysical data collection, processing, imaging, and display. Successful interpreters are experts in identifying features such as channels, mass transport complexes, and collapse features.\r\n<h6><\/h6>\r\nThe problem statement of the hackathon was\u00a0to <strong>train an algorithm to recognize distinct geologic facies in seismic images automatically<\/strong>, producing an interpretation that could pass for that of an expert geologist, or be used as a starting point to speed up human interpretation.\r\n<h6><\/h6>\r\n<h2>The Data<\/h2>\r\n<h6><\/h6>\r\nWe were given the following data set drawn from the Parihaka region off the coast of New Zealand. This\u00a0<a href=\"https:\/\/wiki.seg.org\/wiki\/Parihaka-3D\">data is open to the public\u00a0<\/a>and has been labeled by a Chevron geoscientist. The figure below shows a rendering of two vertical slices and one horizontal slice through the 3D seismic image used in this challenge. Standard cartesian coordinate system is used to plot the image, with X and Y measuring the horizontal positions near the earth\u2019s surface and the Z measuring depth below the earth.\r\n<h6><\/h6>\r\n<p style=\"text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7536 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture1.png\" alt=\"\" width=\"548\" height=\"484\" \/><\/p>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em> Figure 1: 3D views XZ, YZ and XY slices through Parihaka seismic data image (TOP) and corresponding labels (BOTTOM)<\/em><\/span><\/p>\r\n&nbsp;\r\n<h6><\/h6>\r\nThe training dataset is a 3D image represented as a matrix of size 1006 x 782 x 490 real numbers stored in the order or (Z,X,Y).\u00a0 Labels corresponding to the training data are similarly arranged and consists of integers with values ranging between 1 to 6.\u00a0 Figure 2 below shows the intensity plot of the echoes and the corresponding labels for each pixel in one 2D cross-sectional view of an XZ slice.\r\n<h6><\/h6>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7623 size-large\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture2-1-1024x378.png\" alt=\"\" width=\"1024\" height=\"378\" \/>\r\n<p style=\"text-align: center;\"><em><span style=\"font-size: 12px;\">\r\nFigure 2: 2D cross-sectional view of XZ slice (LEFT), and pixel-by-pixel classification of image in 6 facies (RIGHT)<\/span><\/em><\/p>\r\n&nbsp;\r\n<h6><\/h6>\r\n<h2>Our Approach<\/h2>\r\n<h6><\/h6>\r\nMost of the current techniques for automated seismic facies labeling were using convolution neural networks for semantic segmentation [1][2][3].\u00a0 However, many of these methods had an issue of overfitting, and mentioned that the trained algorithm was only applicable to the survey region in proximity to the model training dataset.\u00a0 If the algorithm was used on a dataset from a different geographic location, the model would likely need retraining.\r\n<h6><\/h6>\r\nWe wanted to leverage the work already done in this domain and come up with a technique which is less susceptible to overfitting and could be applied to a much wider geographical area without the need of retraining.\r\n<h6><\/h6>\r\nThat is when we thought of taking a <strong>signal-based approach<\/strong>: since the 3D image volume is constructed from 1D echo signals, perhaps there is some potential of leveraging the unique signatures of these echoes across different facies.\r\n<h6><\/h6>\r\nFigure 3 shows a small section of the 2D image with signals superimposed on the facies. Upon close inspection we can see that each signal, also referred to as a \"trace\", has a distinct signature when it encounters different facies.\u00a0 For instance, at the transition from \"dark blue\" to \"green\" facies in the middle of image, the signal has a burst of high echo-amplitudes rapidly oscillating, whereas the interface below that between \"light blue\" and \"dark blue\" region has slower oscillations with a lower amplitude. Expert geologists often look for these features in the vertical sequence of pixel values to identify the key interfaces between different facies.\r\n<h6><\/h6>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7647 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture3a.png\" alt=\"\" width=\"800\" height=\"506\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>\r\nFigure 3: Plots of image values (red) as a function of depth, superimposed on the facies interpretation in a small section. Note that that a burst of high echo-amplitudes rapidly alternating between positive and negative values is characteristic of the transition between \u201cblue\u201d and \u201cgreen\u201d facies across the middle part of the image. <\/em><\/span><\/p>\r\n&nbsp;\r\n<h6><\/h6>\r\nNext, we used a Recurrent Neural Network (RNN) architecture to train a sequence-by-sequence classification network using the input traces, but in our preliminary attempts the network was failing to converge.\u00a0 This was primarily due to the signal length being is quite long and the distinct signal features changing very rapidly with time.\u00a0 \u00a0If we could separate the unique facies signatures into separate channels, we might have a better chance of training the network.\r\n<h6><\/h6>\r\nWe decided to utilize a wavelet multiresolution analysis technique: multi-resolution analysis (MRA) uses discrete wavelet transform to break the signal into components which decomposes the variability of the data into physically meaningful and interpretable parts. In our case we used MRA directly from <a href=\"https:\/\/www.mathworks.com\/help\/wavelet\/ref\/signalmultiresolutionanalyzer-app.html\">Signal Multiresolution App<\/a> in MATLAB, and after experimenting through <a href=\"https:\/\/www.mathworks.com\/help\/wavelet\/gs\/choose-a-wavelet.html\">various discrete wavelets,<\/a> we got the best decomposition results with \u2018fk14\u2019 wavelet and divided the signal into 5 levels.\r\n<h6><\/h6>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7653 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture4a.png\" alt=\"\" width=\"800\" height=\"424\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>Figure 4: Multiresolution decomposition of the original signal into four levels + Approximation using fk14 wavelet. This is done using Signal Multiresolution App in MATLAB<\/em><\/span><\/p>\r\n&nbsp;\r\n<h6><\/h6>\r\nWe also generated MATLAB code directly from this app by selecting the export option, to apply the same wavelet decomposition with MRA on all signals.\r\n<h6><\/h6>\r\n<pre><span class=\"comment\">% load the training data and labels <\/span>\r\nload data_train.mat; \r\nload labels_train.mat; \r\n\r\n<span class=\"comment\">% Convert the data to double and labels to categorical datatype  <\/span>\r\ndata = double(data); \r\nlabels = categorical(labels); \r\n <span class=\"comment\">% Apply the maximal overlap discrete wavelet transform on all traces  <\/span>\r\ndataMRA = zeros([size(data),5]); \r\nparfor ii = 1 : 782\r\n    for jj = 1:590\r\n      dataMRA(:,ii,jj,:) = modwt(data(:,ii,jj), 'fk14',4)'; \r\n    end\r\nend\r\n<\/pre>\r\n<h6><\/h6>\r\nNow we have 5 channels for each trace. To capture the correlation of nearby traces we grouped 3x3 traces in the XY plane together and used that to train the same labels of the middle trace. This was done assuming the signals resolution in the XY plane is low enough that the seismic features do not change across 3x3 sample grid. Figure 5 shows how the dataset was grouped into 3X3 grid for 5 channels for each trace.\r\n\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7659 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture5a.png\" alt=\"\" width=\"800\" height=\"406\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>Figure 5: Arranging the data into training set<\/em><\/span><\/p>\r\n&nbsp;\r\n<pre>dataTrain = {};\r\nlabelsTrain = {}; \r\nfor ii = 2: 782-1 \r\n    for jj = 2:590-1\r\n      tempData = permute((dataMRA(:,ii-1:ii+1, jj-1:jj+1, :)), [1 4 2 3]); \r\n      dataTrain(ii+jj-3,1) = {reshape(tempData, [1006 45])'} ; \r\n      labelsTrain(ii+jj-3,1) = {labels(:,ii,jj)'}; \r\n    end\r\nend\r\n<\/pre>\r\n<h2><\/h2>\r\nAt this stage we also divided our dataset into training and validation sets to be used during training. To make our network robust, we randomly chose 1000 traces out of 782x590 traces for training and used the remaining for network validation.\r\n<h6><\/h6>\r\n<pre>idx = randperm(size(dataTrain,1)); \r\n\r\n<span class=\"comment\">% Train data and labels <\/span>\r\ntrainData = dataTrain(idx(1:1000)); \r\nvalData = dataTrain(idx(1001:end)); \r\n\r\n<span class=\"comment\">% Test data and labels <\/span>\r\ntrainLabel= labelsTrain(idx(1:1000)); \r\nvalLabel = labelsTrain(idx(1001:end)); \r\n<\/pre>\r\n<h6><\/h6>\r\nNext, we were ready to architect our deep learning network for training.\u00a0 The dataset was arranged to feed into an RNN sequence-by-sequence in the Z direction.\u00a0 Initially we started with Long Short-Term Memory (LSTM) layers but after a few iterations realized that a Gated Recurrent Unit (GRU) layer was giving us a better performance.\u00a0 The deep learning layers were constructed using Deep Network Designer app in MATLAB and analyzed using the network analysis tool.\u00a0 Figure 6 shows the full architecture of the network on Deep Network Analyzer App and its analysis.\u00a0 If you look at the network, we have the first layer being Sequence Input layer with an input size of 45 (3x3x5 channels), and the final classification layer is of size 6x1 corresponding to the scores it will predict for each label class.\r\n<h2><\/h2>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7632 size-large\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture6-1-999x1024.png\" alt=\"\" width=\"999\" height=\"1024\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>Figure 6: Deep Network Designer App to architect the RNN layers (top) and the network analysis (bottom)<\/em><\/span><\/p>\r\n&nbsp;\r\n\r\nWe can directly generate the MATLAB code for the layer architecture by exporting code from the app.\r\n<h6><\/h6>\r\n<pre>inputSize = [45];\r\nnumHiddenUnits1 = 20;\r\nnumHiddenUnits2 = 30;\r\nnumClasses = 6;\r\n\r\nGRUlayers = [ ...\r\nsequenceInputLayer(inputSize,'Name','InputLayer',...\r\n'Normalization','zerocenter')\r\ngruLayer(numHiddenUnits1,'Name','GRU1','OutputMode','sequence')\r\ndropoutLayer(0.35,'Name','Dropout1')\r\ngruLayer(numHiddenUnits2,'Name','GRU2')\r\ndropoutLayer(0.2,'Name','Dropout2')\r\nfullyConnectedLayer(numClasses,'Name','FullyConnected')\r\nsoftmaxLayer('Name','smax');\r\nclassificationLayer('Name','ClassificationLayer')];<\/pre>\r\n<h2><\/h2>\r\nAfter this step, we defined the training options, for deep network training. The training was performed on a single NVIDIA Ampere A100 GPU using the MATLAB AWS Reference architecture cloud image. Figure 7 shows the deep learning training progress.\r\n<h2><\/h2>\r\n<pre>maxEpochs = 300;\r\nminiBatchSize = 15;\r\n\r\noptions = trainingOptions('adam', ...\r\n    'ExecutionEnvironment','auto', ...\r\n    'L2Regularization',1e-3,...\r\n    'InitialLearnRate',1e-3, ...\r\n    'MaxEpochs',maxEpochs, ...\r\n    'MiniBatchSize',miniBatchSize, ...\r\n    'Shuffle','every-epoch',...\r\n    'Verbose',0,...\r\n    'Plots','training-progress', ...\r\n    'ValidationData', {valData, valLabel});\r\n\r\n[netGRU,infoGRU] = trainNetwork(dataTrain,labelsTrain,GRUlayers,options);<\/pre>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7662 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture9a.png\" alt=\"\" width=\"800\" height=\"439\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em> Figure 7: Training progress for deep learning network<\/em><\/span><\/p>\r\n&nbsp;\r\n<h2><\/h2>\r\n<h2>Results<\/h2>\r\nThe competition ran for a duration of 2 weeks, and the <a href=\"https:\/\/seg.org\/News-Resources\/News\/page\/ai-applied-geoscience-hackathon-results-released\">results were declared<\/a> on April 22<sup>nd<\/sup> 2021. The competition had several highs and lows. \u00a0We literally had 3 sleepless nights on the weekend before the submission.\u00a0 We had to iterate over different approaches before we came up with our final solution. We initially started out with training LSTMs on raw signal and gradually kept adding additional techniques, before coming up with the final solution.\r\n<h6><\/h6>\r\nThere were 3 metrics to judge the quality of submission:\r\n<ol>\r\n \t<li>Facies-weighed F1 score with different weighting among the facies: Highest weights for facies 5 and 6 since these were geologically most important.<\/li>\r\n \t<li>Facies-weighted percentage of pixels correct: Highest weights for facies 5 and 6 since these were geologically most important.<\/li>\r\n \t<li>Interface-weighted F1-score: F1-score is calculated for each pixel, with pixels within 10 samples of an interface were given 20 times the weight of all other samples.<\/li>\r\n<\/ol>\r\n<h2><\/h2>\r\nMathWorks was declared the winner for test dataset 1. Our submission was ruled 'geologically consistent' and F1-weighted score was more than double of the next competing team! Our approach was called \u201cunique\u201d by our mentor because it is signal processing heavy and not completely deep learning driven.\r\n<h2><\/h2>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7701 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture10b.png\" alt=\"\" width=\"800\" height=\"259\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>Figure 8: Leaderboard for the results with MathWorks having the top score. Note the F1-Weighted score discrepancy between MathWorks and other teams!<\/em><\/span><\/p>\r\n&nbsp;\r\n\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7563 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture11.png\" alt=\"\" width=\"624\" height=\"291\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>Figure 9: Weighted F1 score calculated for test dataset<\/em><\/span><\/p>\r\n&nbsp;\r\n<h2><\/h2>\r\n<h2>What's Next<\/h2>\r\n<h2><\/h2>\r\n<ol>\r\n \t<li>We now have a novel fully functioning solution to seismic facies classification problem (we'll be happy to send you code if you reach out to <a href=\"mailto:deep-learning@mathworks.com\">deep-learning@mathworks.com<\/a>). We strongly believe this approach will help overcoming the limitations with convolution neural networks.<\/li>\r\n \t<li>We will combine the CNNapproach [1][2] with the RNN deep learning network approach with a goal to get the best prediction with both images and signals approach. Figure 10 shows the future work architecture, where we would train two different 2D UNets across the XZ and YZ plane and combine it with the RNN network predictions.\u00a0 For each trace we would have classifications from 3 networks, and a pooling algorithm will analyze the scores and pick out the final prediction class.<\/li>\r\n<\/ol>\r\n<img decoding=\"async\" loading=\"lazy\" class=\"wp-image-7671 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture12a.png\" alt=\"\" width=\"800\" height=\"232\" \/>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 12px;\"><em>\r\nFigure 10: Future work to combine UNet with RNN for facies classification<\/em><\/span><\/p>\r\n&nbsp;\r\n<h2>References<\/h2>\r\n<u>[1]<\/u> Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. <em>Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs<\/em>. IEEE transactions on pattern analysis and machine intelligence, 40(4):834\u2013848, 2018b.\r\n<h6><\/h6>\r\n<u>[2]<\/u> Zengyan Wang, Fangyu Li, Thiab R. Taha and Hamid R. Arabnia. <em>Improved Automating Seismic Facies Analysis Using Deep Dilated Attention Autoencoders. <\/em>Conference: 2019 IEEE\/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)\r\n<h6><\/h6>\r\n<u>[3]<\/u> Geng, Z., Wang, Y. <em>Automated design of a convolutional neural network with multi-scale filters for cost-efficient seismic data classification<\/em>.\u00a0Nat Commun\u00a011,\u00a03311 (2020). <a href=\"https:\/\/doi.org\/10.1038\/s41467-020-17123-6\">https:\/\/doi.org\/10.1038\/s41467-020-17123-6<\/a>\r\n<h6><\/h6>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2021\/07\/Picture1.png\" onError=\"this.style.display ='none';\" \/><\/div><p>The following post is from Akhilesh Mishra, Mil Shastri and Samvith V. Rao from MathWorks here to talk about their participation and in a Geoscience hackathon. Akhilesh and Mil are Applications... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/deep-learning\/2021\/08\/03\/mathworks-wins-geoscience-ai-gpu-hackathon\/\">read more >><\/a><\/p>","protected":false},"author":156,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/7515"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/users\/156"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/comments?post=7515"}],"version-history":[{"count":40,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/7515\/revisions"}],"predecessor-version":[{"id":7713,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/7515\/revisions\/7713"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/media?parent=7515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/categories?post=7515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/tags?post=7515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}