熔池 沉积_用于3D打印的AI(第3部分):异常熔池分类的纠缠变分自动编码器
熔池 沉積
This article is part 3 of the AI for 3-D printing series. Read part 1 and part 2.
本文是3-D打印AI系列的第3部分。 閱讀 第1 部分 和 第2部分 。
The usage of an autoencoder provides a means of describing melt pool images with fewer parameters. Essentially, this is a form of data compression. However, as illustrated in part 2, the latent vectors encoded by the autoencoder are highly-packed and appeared in clusters form. As a result, the latent space is not smooth and continuous. It is possible to have severe overfitting in the latent space where two latent vectors which are near to each other look very different when reconstructed. This is due to the absence of regularisation term to control how the data should be compressed in its loss function.
自動編碼器的使用提供了一種描述具有較少參數(shù)的熔池圖像的方法。 本質(zhì)上,這是數(shù)據(jù)壓縮的一種形式。 但是,如第2部分中所述 ,由自動編碼器編碼的潛矢量高度堆積,并以簇的形式出現(xiàn)。 結(jié)果,潛在空間不平滑和連續(xù)。 在潛在空間中可能存在嚴(yán)重的過度擬合,在重構(gòu)時,彼此靠近的兩個潛在矢量看起來非常不同。 這是由于缺少正規(guī)化項來控制數(shù)據(jù)在其損失函數(shù)中應(yīng)如何壓縮。
Well, you can say that the autoencoder compresses data for the sake of compressing and hence it does not necessarily preserve the structure of data in the latent space.
好吧,您可以說自動編碼器是為了壓縮而對數(shù)據(jù)進(jìn)行壓縮的,因此它不一定會在潛在空間中保留數(shù)據(jù)的結(jié)構(gòu)。
This is an issue if we want to have both:
如果我們要同時擁有這兩個問題:
to describe melt pool geometry.
描述熔池的幾何形狀。
It is possible to resolve this issue with a variant of autoencoder. This article presents an automated features extraction methodology for anomalous melt pool detection and classification tasks centred around the usage of a disentangled variational autoencoder. Specifically, the quality data compressing property of a variational autoencoder will be used to extract different melt pool representations.
可以使用自動編碼器的變體來解決此問題。 本文介紹了針對異常熔池檢測和分類任務(wù)的自動特征提取方法,該方法以分散的可變自動編碼器的使用為中心。 具體來說,變式自動編碼器的質(zhì)量數(shù)據(jù)壓縮屬性將用于提取不同的熔池表示形式。
介紹 (Introduction)
A variational autoencoder (VAE) has a similar structure as an autoencoder, except that it is a probabilistic variant of the latter. The usage of a VAE assumes that there are several unobserved data generating factors (also known as representations), each controlling different aspect(s) of the input. Following that, the goal here is to train a VAE to approximate the representations’ distributions so that the encoder can effectively be used as a features extractor.
可變自動編碼器(VAE)具有與自動編碼器類似的結(jié)構(gòu),只是它是后者的概率變體。 VAE的使用假定存在多個未觀察到的數(shù)據(jù)生成因子(也稱為表示形式),每個因子控制輸入的不同方面。 隨后,此處的目標(biāo)是訓(xùn)練VAE以近似表示的分布,以便編碼器可以有效地用作特征提取器。
Generic architecture of a VAEVAE的通用架構(gòu)The generic architecture of a VAE is shown above. Notice that instead of ordinary encoder and decoder, VAE is made up of two probabilistic components . The probabilistic encoder maps the input data X to a latent vector z. On the other hand, the decoder maps any sampled vectors from the latent space back into the original dimension, X’.
VAE的通用體系結(jié)構(gòu)如上所示。 請注意,VAE由兩個概率組件組成,而不是普通的編碼器和解碼器。 概率編碼器將輸入數(shù)據(jù)X映射到潛在向量z 。 另一方面,解碼器將來自潛在空間的所有采樣矢量映射回原始維度X' 。
Loss function of a VAEVAE的損失功能This loss function has two terms in it. The reconstruction loss ensures that the reconstructed data is similar to the input. The second term, also known as the KL-divergence term, is a measure of the difference between the latent distributions of the data and the prior distribution of the latent encoding. It imposes a penalty to the network when it encodes the input into a highly-packed region, thus encouraging the encodings to acquire a distribution similar to the prior distribution, which is assumed to be ~N(0, I).
該損失函數(shù)包含兩個項。 重建損失可確保重建的數(shù)據(jù)與輸入相似。 第二項,也稱為KL散度項 ,是對數(shù)據(jù)的潛在分布與潛在編碼的先驗分布之間的差異的度量。 當(dāng)網(wǎng)絡(luò)將輸入編碼到一個高度打包的區(qū)域時,它將對網(wǎng)絡(luò)造成一定的損失,從而鼓勵編碼獲取類似于先前分布的分布,假定該分布為?N(0,I)。
Joseph provides a very intuitive and clear explanation on VAE in his Medium article. See article attached below:
約瑟夫(Joseph)在其中型文章中對VAE提供了非常直觀,清晰的解釋。 請參閱下面的文章:
To obtain the loss function of a β-VAE the loss function of a VAE is modified by multiplying a factor of β to the KL divergence regularising term.
為了獲得β-VAE的損失函數(shù),通過將β因子乘以KL散度正則項來修改VAE的損失函數(shù)。
The loss funtion of a β-VAE is modified from VAE’s loss function. A relative weightage β is assigned to the KL divergence term.β-VAE的損失功能是從VAE的損失函數(shù)中修改的。 相對權(quán)重β被分配給KL散度項。Essentially, this modification allows us to control the amount of disentanglement between the encoded latent components. A set of latent components is said to be disentangled when each component is relatively sensitive to changes in a single aspect of the representations while being insensitive to the others. In the context of melt pool geometry, when the latent encodings are perfectly disentangled, varying one latent component will only change an aspect of the melt pool geometry. Whereas for normal VAE, it is difficult to understand which aspect of the melt pool geometry is captured by each individual latent component, as varying one latent component results in multiple changing melt pool representations.
從本質(zhì)上講,這種修改使我們可以控制編碼后的潛在分量之間的糾纏量。 當(dāng)每個潛在組件對表示的單個方面的變化相對敏感而對其他表示不敏感時,則將一組潛在組件解開 。 在熔池幾何結(jié)構(gòu)中,當(dāng)潛在編碼完全解開時,更改一個潛分量只會改變?nèi)鄢貛缀谓Y(jié)構(gòu)的一個方面。 而對于正常的VAE,很難理解每個單獨的潛在組分所捕獲的熔池幾何形狀的哪個方面,因為改變一個潛在組分會導(dǎo)致熔池表示形式發(fā)生多次變化。
In this project, β was chosen to be 4 as this value of β empirically gives the best disentanglement effects.
在該項目中,選擇β為4,因為根據(jù)經(jīng)驗,該β值可提供最佳的糾纏效果。
數(shù)據(jù)預(yù)處理 (Data Pre-processing)
With the goal to describe the melt pool geometries in a more precise manner, the melt pool images are cropped from a size of 128x128 into 32x32. This is because the melt pool’s surrounding does not contain much information about its geometry. We also ensure that the centroid of melt pool is aligned with the image’s center.
為了更精確地描述熔池幾何形狀,熔池圖像從128x128的尺寸裁剪為32x32。 這是因為熔池周圍沒有太多關(guān)于其幾何形狀的信息。 我們還確保熔池的質(zhì)心與圖像的中心對齊。
ROI of a melt pool frame.熔池框架的ROI。Min max normalisation is carried out for all cropped video frames. Unlike the one class learning framework, this framework does not rely on any profiling for the normal melt pool. Hence, the data does not need to be pre-sieved.
對所有裁剪的視頻幀執(zhí)行最小最大歸一化。 與一類學(xué)習(xí)框架不同,該框架不依賴于常規(guī)熔池的任何概要分析。 因此,不需要預(yù)先篩選數(shù)據(jù)。
特征提取 (Features Extraction)
By training a β-VAE on the melt pool video frames, the encoder learns the probability distribution of the melt pool latent representations. To explore the encodings, one could sample from specified ranges in the latent dimensions and decode the sampled latent vectors for visualisation.
通過在熔池視頻幀上訓(xùn)練β-VAE,編碼器可以了解熔池潛在表示的概率分布。 為了探索編碼,可以從潛在維度的指定范圍中采樣并解碼采樣的潛在向量以進(jìn)行可視化。
A grid of generated melt pool images with fixed third latent component. (image by author)具有固定的第三潛在分量的生成的熔池圖像的網(wǎng)格。 (作者提供的圖片) A grid of generated melt pool images with fixed second latent component. (image by author)生成的熔池圖像的網(wǎng)格具有固定的第二潛在成分。 (作者提供的圖片)Based on the grid plots of generated images, we observed that:
根據(jù)生成的圖像的網(wǎng)格圖,我們觀察到:
- The first latent component captures the size of melt pool 第一個潛在成分捕獲熔池的大小
- Second latent component captures the roundness of melt pool. The melt pool images get squashed vertically or horizontally. 第二潛在成分捕獲熔池的圓度。 熔池圖像垂直或水平擠壓。
- Third latent component captures the tail length of melt pools. The sign of the third latent component also captures the travelling direction of the melt pool. 第三潛在成分捕獲熔池的尾部長度。 第三潛在成分的符號也捕獲了熔池的行進(jìn)方向。
Also, we can verify that the compression is a quality one as melt pool images smoothly “morph” from one form into another in the latent space. Besides, we can almost perfectly isolate the changes in melt pool geometry when we alter a single latent component. For example, increasing the first latent component changes the size but does almost nothing to the other two aspects.This is what I meant by disentangled representations earlier on.
同樣,我們可以驗證壓縮是一種高質(zhì)量的壓縮,因為熔池圖像在潛在空間中從一種形式平滑地“變形”為另一種形式。 此外,當(dāng)我們改變單個潛在成分時,我們幾乎可以完美地隔離熔池幾何形狀的變化。 例如,增加第一個潛在分量會改變大小,但對其他兩個方面幾乎沒有任何作用,這就是我之前所說的解纏表示的意思。
Learn more about the disentangled variational autoencoder from Arxiv Insights:
從Arxiv Insights了解有關(guān)解纏的變分自動編碼器的更多信息:
Introduction to variational autoencoders from Arxiv Insights.Arxiv Insights的變體自動編碼器簡介。If we examine the distributions of the latent components of the training data:
如果我們檢查訓(xùn)練數(shù)據(jù)潛在成分的分布:
Distributions of (a) Z1, (b) Z2 and (c) Z3(a)Z1,(b)Z2和(c)Z3的分布The first and second latent components resemble Gaussian distributions whereas the third latent component resemble a bimodal distribution (a superposition of two Gaussian distributions). The bimodal distribution of the third latent component is due to the meander scanning strategy employed which causes melt pool to travel in a zigzag pattern. All distributions are centred around 0 and have a close to unity standard deviation due to the regularizing force applied by the KL divergence term in β-VAE’s loss function.
第一和第二潛分量類似于高斯分布,而第三潛分量類似于雙峰分布(兩個高斯分布的疊加)。 第三潛在組分的雙峰分布?xì)w因于所采用的曲折掃描策略,該策略使熔池以鋸齒形行進(jìn)。 由于KL發(fā)散項在β-VAE損失函數(shù)中施加的正則化力,所有分布都以0為中心,并且具有接近統(tǒng)一的標(biāo)準(zhǔn)偏差。
異常檢測與分類 (Anomalies Detection and Classification)
Next, the encoded melt pools are presented in the form of scatter plots.
接下來,以散點圖的形式顯示編碼的熔池。
Scatter plot of Z2 vs Z1 with anchored melt pool images. (image by author)Z2 vs Z1與錨定熔池圖像的散點圖。 (作者提供的圖片) Scatter plot of Z3 vs Z1 with anchored melt pool images. (image by author)Z3 vs Z1與錨定熔池圖像的散點圖。 (作者提供的圖片)Based on the scatter plots, the encodings seem to agree qualitatively with the latent representations. Besides, several anomalies are clearly encoded far away from the denser region(s) in the latent space. This suggests the usage of Euclidean Distance metric from some reference point(s) as an anomaly measure. Based on the visualisation, it is also sensible to categorise the datapoints into clusters. Following that, the distance of melt pools from their cluster’s centroid can be computed and used as the anomaly metric.
基于散點圖,編碼似乎與潛在表示在質(zhì)量上一致。 此外,在遠(yuǎn)離潛在空間中較密集區(qū)域的地方,清楚地編碼了幾個異常。 這建議使用從某個參考點開始的歐幾里得距離度量作為異常度量。 基于可視化,將數(shù)據(jù)點歸類為群集也是明智的。 然后,可以計算熔池距其簇的質(zhì)心的距離,并將其用作異常度量。
Conceptually, this means that the more a given set of melt pool characteristics deviates from their average values the more anomalous the melt pool is.
從概念上講,這意味著給定的一組熔池特征偏離其平均值越多,則熔池異常越多。
Scatter plots of (a) all data points, (b) outliers (in orange) identified by DBSCAN and normal data points (in blue), (c) K-Means Clustering fitted on the normal data points and (d) all data points and the two identified clusters. (image by author)(a)所有數(shù)據(jù)點,(b)DBSCAN識別的異常值(橙色)和正常數(shù)據(jù)點(藍(lán)色)的散點圖,(c)擬合在正常數(shù)據(jù)點上的K均值聚類和(d)所有數(shù)據(jù)點和兩個確定的集群。 (作者提供的圖片)A density based clustering algorithm, DBSCAN is used to clean up the data and then K-Means Clustering with k=2 is fitted on the cleaned dataset. The centroids of those clusters will be stored for Euclidean distance computation during testing. The distance metric will be used as a measure for the melt pool degree of anomaly.
使用基于密度的聚類算法DBSCAN清理數(shù)據(jù),然后將k = 2的K-Means聚類擬合到清理后的數(shù)據(jù)集。 這些簇的質(zhì)心將在測試期間存儲,以進(jìn)行歐幾里得距離計算。 距離度量將用作熔池異常程度的度量。
Three different supervised classifiers, Support Vector Machine (SVM), K-Nearest Neighbours (KNN) and Random Forest (RF) are utilised for the melt pool anomalies classification task. For this time, we explicitly classified the type of melt pools into a few categories — melt pool with unstable tail, plume and large melt pool.
三種不同的監(jiān)督分類器,支持向量機(SVM),K最近鄰(KNN)和隨機森林(RF)用于熔池異常分類任務(wù)。 這次,我們將熔池的類型明確分類為幾類-具有不穩(wěn)定尾部,羽狀流和較大熔池的熔池。
The optimal hyperparameters of the classifiers were obtained with grid search cross validation with five folds. Finally, the testing dataset is used to quantify the performance of the classifiers. The classification results are summarised as below:
分類器的最佳超參數(shù)是通過五次網(wǎng)格搜索交叉驗證獲得的。 最后,測試數(shù)據(jù)集用于量化分類器的性能。 分類結(jié)果總結(jié)如下:
Confusion matrix of (a) SVM, (b) KNN and (c) RF(a)SVM,(b)KNN和(c)RF的混淆矩陣Some of the correct classifications are shown below:
一些正確的分類如下所示:
Correct classifications (a) Unstable Tail, (b) Plume and (c) Large melt pools.正確分類(a)不穩(wěn)定的尾巴,(b)羽狀物和(c)大型熔池。Our VAE framework can now assign anomaly metric and additionally it possesses the ability to classify melt pools based on their geometries.
我們的VAE框架現(xiàn)在可以分配異常度量,此外,它還具有根據(jù)其幾何形狀對熔池進(jìn)行分類的功能。
Example usage of this all-in-one anomaly classification and detection framework on three lines of scan:
在三行掃描中使用這種多合一異常分類和檢測框架的示例用法:
Predicted categories of melt pool and anomaly metric on top of each frame.每幀頂部的熔池預(yù)測類別和異常度量。一些想法 (Some Thoughts)
The β-VAE framework has a few advantages over an end-to-end supervised deep learning approach (end-to-end deep learning approach being, train a supervised neural network on labelled data without any features extraction):
與端到端監(jiān)督式深度學(xué)習(xí)方法相比,β-VAE框架具有一些優(yōu)勢(端到端深度學(xué)習(xí)方法是,在不提取任何特征的情況下在標(biāo)記數(shù)據(jù)上訓(xùn)練監(jiān)督神經(jīng)網(wǎng)絡(luò)):
未來的工作 (Future Work)
Future work is likely to involve training the β-VAE with a more curated training dataset. With known limitation (working within a specified set of printing parameters), this framework can then be incorporated into existing LPBF monitoring system. Tackling this problem with sequential models is another interesting approach yet to be experimented. Essentially, we can model melt pool dynamics as a time series problem. This makes sense as anomalous instances such as plumes are characterised by their rapidly changing shapes across multiple frames. Perhaps viewing the problem with this new perspective will be the key to building a more accurate framework.
未來的工作可能涉及使用更有效的訓(xùn)練數(shù)據(jù)集訓(xùn)練β-VAE。 在已知限制下(在指定的打印參數(shù)集內(nèi)工作),此框架可以并入現(xiàn)有的LPBF監(jiān)視系統(tǒng)中。 用順序模型解決這個問題是另一種有待試驗的有趣方法。 本質(zhì)上,我們可以將熔池動力學(xué)建模為時間序列問題。 這是有道理的,因為異常實例(例如羽流)的特征是它們在多個框架中快速變化的形狀。 也許用這種新觀點來觀察問題將是建立更準(zhǔn)確的框架的關(guān)鍵。
結(jié)束語 (Concluding Remark)
In this article, we explored more on the data compressing capability of a disentangled variational autoencoder. From various visualisations, we then verified that the resulting latent space is smooth and continuous in the sense melt pool images which are similar are encoded closely to each other. Furthermore, with this framework we can also extract useful and interpretable melt pool representations for anomalies detection and classification. With a few supervised classifiers trained on the latent representations, we also showed that this framework can be used to classify anomalies and quantify their degree of anomaly simultaneously.
在本文中,我們進(jìn)一步探討了糾纏變分自動編碼器的數(shù)據(jù)壓縮能力。 通過各種可視化,我們?nèi)缓篁炞C了在相似的相似感官熔池圖像彼此緊密編碼的意義上,所得的潛在空間是平滑且連續(xù)的。 此外,借助此框架,我們還可以提取有用且可解釋的熔池表示形式,以進(jìn)行異常檢測和分類。 借助在潛在表示上訓(xùn)練的一些監(jiān)督分類器,我們還表明該框架可用于對異常進(jìn)行分類并同時量化其異常程度。
Thanks for reading :)
謝謝閱讀 :)
翻譯自: https://towardsdatascience.com/ai-for-3-d-printing-part-3-disentangled-variational-autoencoder-for-anomalous-melt-pools-aaed53b80140
熔池 沉積
總結(jié)
以上是生活随笔為你收集整理的熔池 沉积_用于3D打印的AI(第3部分):异常熔池分类的纠缠变分自动编码器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 现在的蔬菜水果比以前的难吃,不是你的错觉
- 下一篇: openai-gpt_您可以使用Open