Metal search and ... neural network

    The principle of operation of a pulse metal detector
    One of the popular design options for metal search devices is a pulse ( pulse induction ( PI )) metal detector — an unpretentious and reliable apparatus (good detection depth, resistance to increased soil salinity, ability to work in salt water), having various applications - from military affairs (traditional users of “impulse”) to the search for gold (this hobby is particularly popular in Australia).
    But he also has a significant drawback - great difficulties with discrimination, i.e. determining the type of target, for example, to find out - is it made of ferrous metal or black, or is it possible to distinguish an anti-personnel mine in a plastic case from a handful of metal debris? What is the cause of this problem?
    Consider the principle of operation of a pulse metal detector.


    Electronic key (normally MOSFET , withstand voltage of several hundred volts - for example, in this creation Malaysian engineers applied popular IRF740 , and in this project based on a programmable analog-digital matrix GreenPAK use less powerful IRF730 ) manages the connection of the search coil to the power source (accumulator battery). When a control pulse is applied to the gate of the transistor (usually with a frequency of several tens to hundreds of hertz) MOSFETopens - the circuit is closed, an increasing (through the transition process) current begins to flow through the coil. We are waiting for several tens or hundreds of microseconds of current rise to the desired level and ... breaking the circuit - the control impulse is over. Current$ i $ through the coil and, accordingly, the magnetic flux $ \ Phi $the coil decreases sharply (to speed up the process of closing the MOSFET, the control impulse is not supplied directly to the gate, but through a special driver), which, due to the phenomenon of electromagnetic induction, causes the appearance of EMF of self-induction$ e_L = -w {d \ Phi \ over dt} $and a sharp increase in voltage on the coil. Then the voltage level on the coil starts to decrease. But if a conducting object (“target”) is located near the coil, then the magnetic flux through the coil decreasing with the current induces eddy currents$ i_to $in this target. These eddy currents create their own magnetic flux.$ \ Phi_in $who is trying to maintain the damped magnetic field of the coil. This effect leads to an increase in the voltage attenuation duration of the coil, which is an indicator of the absence or presence of the target (the decision is made either by integrating the signal and estimating the integral value ( a ) or based on the signal values ​​at several points ( b )):


    Note : pulses can be and bipolar (for example, in the metal detector Vallon VMH2 - a classic device used in mine clearance):

    ( source )
    The average value (constant component) of the magnetic field created by the metal detector is close to zero, which should (as cautiously written in the catalogs, “according to the manufacturer”) prevent undermining when searching for mines reacting to the magnetic field (although, as stated in "Metal detector handbook for humanitarian demining" , with humanitarian demining such an incident is unlikely).

    Along with the described variant with one coil, combining the functions of transmitting and receiving, there are pulsed metal detectors with two separate coils. This scheme is applied not only in the field of metal search, but also in flaw detection ( Pulsed Eddy Current (PEC) Testing ) - reference 1 , reference 2 . In this case, one of the coils (transmit / drive coil ) serves to excite eddy currents in the target, and the other ( receive / pickup coil ) is a magnetic field sensor. This approach makes it possible to analyze the magnetic field not only at the stage of decrease (after disconnecting the power source from the transmitting coil), but also at the increasing stage (after connecting the power source to the transmitting coil):

    Here is an excellent description of this technology:
    Decay Method for High Purity Metals

    The Problem of Discrimination
    The problem of recognition of the type of metal arises from the fact that the resulting voltage curve on the coil is influenced by the size and shape of the target, its distance from the coil and electrical (conductivity$ \ sigma $) and magnetic (magnetic permeability $ \ mu $) properties of the target material.
    Here are some quotes on this topic:

    (source: Ahmet S. Turk, Koksal A. Hocaoglu, Alexey A. Vertiy Subsurface Sensing)
    It has been the rule of law that it has been used to detect the metal.
    ( source )
    ... alter the signal
    ( source )
    Many attempts have been made to create pulsed metal detectors capable of distinguishing between iron, silver and copper, but all these attempts have had very limited success. This is due to the physics of the pulse signal.
    ( source )

    One approach to solving this problem is to use Double-D ( DD ) coils instead of the usual monoloop ( monoloop ), for example, in popular Minelab GPX series metal detectors :

    ( source )
    In this coil, the transmitting ( TX ) and receiving ( RX ) windings:

    ( source )
    In this case, the signal from the target is analyzed not only when decreasing, but also when current increases in the transmitting coil. But this discrimination is not very reliable:

    ( source )
    But what about the single-loop reel? In many works ( reference 1 reference 2 reference 3 ) it is indicated that the signal in the coil from the target can be represented as a weighted sum of damped exponential signals whose maximum values ​​and time constants are individual and depend on the material, size and shape of the target:
    $ u (t) = \ sum_ {i = 1} ^ NA_ie ^ {- t / \ tau_i} $
    In the work " Discrimination experiments with the US Army's standard metal detector, " it is reported that in experiments conducted by the authors of the article, small objects were well characterized by one exhibitor$ Ae ^ {- {\ alpha} t} $, and for large objects, two were needed - $ Ae ^ {- {\ alpha} t} + Be ^ {- {\ beta} t} $.
    In this article it states that the time constant of the exponential component can be represented as the ratio of the equivalent inductance and resistance$ {\ tau} _e = {L_e \ over R} $ and gives its expression for a cylinder with a base radius $ R $ and tall $ h $:
    $ \ tau = {{\ mu_r \ mu_0 \ sigma R ^ 2 h} \ over 8} $
    In this work is an expression of the decay time constant of the eddy currents for a sphere of radius$ R $:
    $ \ tau = {{\ mu_r \ mu_0 \ sigma R ^ 2} \ over \ chi ^ 2} $,
    where$ \ chi $ - the result of solving the equation $ tg \ chi = {{(\ mu_r-1) \ chi} \ over {\ mu_r-1 + {\ chi} ^ 2}} $

    Note : such analytical expressions can be obtained only for simple symmetric bodies. Therefore, to study the eddy currents, you can use software packages for numerical simulation of electromagnetic processes. As an example, the simulation of electromagnetic brakes on eddy currents in the COMSOL Multiphysics package :

    ( source )

    As can be seen, the expressions for the time constant together include the magnetic permeability, electrical conductivity and dimensions of the target. It is not so simple to single out the influence of these factors separately, which is required for discrimination.
    In the already mentioned this work It is proposed to use the Bayesian classifier to distinguish mines from metal debris (two hypotheses are tested: $ H_0 $ - garbage, $ H_1 $- mine), but this requires additional estimates of the symmetry of the signal, etc. (it is interesting that the composition of the factors used includes the signal energy, estimated as$ \ sum_ {i = 1} ^ N {u_i ^ 2 \ cdot {\ Delta} t} $).
    For illustration, I built on the screen of my experimental stand an original design of voltage graphs on a coil for various targets:
    no target:

    target No. 1 (ferrous metal) at different distances from the coil:

    target No. 2

    (ferrous metal) : target No. 3 (ferrous metal) at different distances from the coil:

    target No. 4 (non-ferrous metal):

    As you can see, for ferrous metal targets, due to the higher magnetic permeability, the initial signal level is higher than for non-ferrous metal targets, but the signal decays faster due to lower specific electric matic conduction.
    NEUROSET
    How, based on these very weak signs, to classify the target, especially when the distance from the target to the metal detector coil is changed? We have a wonderful tool - an artificial neural network. Neural networks play tic-tac-toe , blackjack , poker , predict the weather and quality of wine , calculate the resistance to the movement of agricultural equipment ... So apply the neural network to solve the problem of discrimination!
    Proof that this is possible is provided by the article “Improving the Neural Network” by Iranian researchers: Data for a Neural Network


    To fill the data array for learning, validating and testing the neural network, pressing the button on the body of my stand measures 8 points (the number of points chosen empirically) on the voltage curve and outputs ATmega328 ADC samples in symbolic form to the serial port connected to the computer’s USB connector.
    In the stand in front of the input of the operational amplifier, the diode limiter is turned on, but, as modeling showed, in the section of interest (with low voltage on the coil), its influence on the voltage value is negligible:

    Turning on the logging mode in the terminal program (for example, Tera Term ), we get “raw »Data (for convenience, comments can be added to Tera Term ). A little utility written in Go, converts this data into a format suitable for consumption by the neural network:
    i1 i2 ... i8 o1 o2
    Example of a string with a set of values:
    588 352 312 280 252 240 206 192 0 1
    Input data i1 i2 ... i8 are samples of a 10-bit ADC in the range 0 ... 1023.
    Output o1 o2 are presented in the form of:
    a "black metal" ( 1, 0), "ferrous metal" (0 1 ).
    I collected data in the presence of a ferrous metal target near the coil (target No. 1, target No. 2), with a target made from non-ferrous metal (target No. 3, target No. 4), and the targets were located at different distances from the search coil. For further use, data were selected corresponding to a sufficient signal level.- with at least two nonzero values. The data sets corresponding to the overload of the ADC input were also discarded - containing several maximum possible values ​​(1023):

    For illustration, I performed a regression analysis for one data set:

    The received signal is well described by the sum of two exponents:
    $ 437.9e ^ {- {0,29} x} + 93.1e ^ {- {12,1} x} $where $ x $- reference number.
    I selected most of the data (110 sets of values, the train.dat file ) for training ( training dataset ) (when loading they are further subjected to randomization - mixing), and a smaller part (40 sets, the test.dat file ) for the validation of the neural network ( validation dataset ) - cross-checks in its simplest form (on holdout dataset ).
    The structure of a neural network
    The created classical neural network of direct propagation will have three layers: the
    input layer - from 8 neurons - perceives the points of the voltage curve;
    hidden layer - from three neurons;
    output layer- from two neurons.

    (network "8-3-2") The
    Iranians in the above work used two readings (respectively, two input neurons) and three neurons in two hidden layers (the neural network scheme is depicted and described in their article not very clearly).
    Neutron state$ z $ defined as weighted ($ w $ - weight) amount $ n $ input signals $ x $ (perceived by dendrites) and displacement $ b $:
    $ z = \ sum_ {i = 1} ^ nw_i \ cdot x_i + w_ {i + 1} \ cdot b $
    (adding the offset can be represented as the effect of additional bias neuron)
    neuron condition is converted into an output signal (at the axon terminals) via activation function$ f $:
    $ y = f (z) $
    The input signals of the neural network arriving at the neurons of the input layer are transmitted to their outputs unchanged, which corresponds to the linear activation function:
    $ f (z) = z $
    For the neurons of the hidden and output layer, a nonlinear activation function, “sigmoid,” is used, or rather its very popular option — the logistic function — with an interval of values ​​(0; 1):
    $ f (z) = {1 \ over {1 + e ^ {- z}}} $
    This choice of activation function is great for non-negative ADC counts. But this requires, of course, the normalization of the input values ​​- we divide them by 1024, which guarantees a value less than 1. The
    Iranians used the hyperbolic tangent as an activation function.
    The values ​​of the output neurons of the output layer determine the results of the neural network. The neuron with the maximum output value will indicate the decision (winning class) made by the network: the first class is “ferrous metal”, the second class is “non-ferrous metal”.
    The Iranians used three output neurons pointing to iron, copper and lead. Python is
    often used to solve machine learning problems - PyTorch , Keras , TensorFlow, CNTK , libraries and frameworks for neural networks are also created for JavaScript - Synaptic , Java - Deeplearning4j , C ++ - CNTK , and MATLAB is not far behind .
    But for the subsequent “field” use in the metal detector, these frameworks / libraries are of little use, so for a detailed understanding of the process I built my neural network without using additional INS support libraries. Neural network, of course, you can write on BASIC :-). But under the influence of my subjective preferences, I chose Go .
    Training and validation of the neural network
    When creating a network, weights are initialized with random values ​​in the range (-0.1; 0.1).
    I used the stochastic gradient descent ( SGD ) method for network learning .
    The neural network performs a single iteration of the learning process, using one of the learning sets provided in sequence. In this case, the forward propagation operation is first performed — the network processes the input set of signals from the training example. Then, based on the obtained solution, the back propagation algorithm is implemented. To update the weights in the learning process, I applied the formula of "vanilla" gradient descent, which uses one hyperparameters - learning rate coefficient ( learning rate The )$ \ alpha $ (sometimes denoted by $ \ eta $), i.e. the second popular hyper parameter is not used - factor of the moment$ \ gamma $( momentum factor ).
    The learning epoch ends after using the entire training data set. After the end of an epoch, the mean square error ( Mean Squared Error ( MSE )) of training is calculated , the neural network is fed a set of values ​​for validation (cross-check on pending data), the mean square of the validation error is determined, the accuracy of predictions ( accuracy ) and the cycle repeats. The cycle stops after reaching the required level of the mean square of the validation error.
    After compiling the source code ( nn4md.go file ) and launching the executable file, the console displays the learning process — the epoch number ( Epoch ), the average square of the learning and validation errors (MSE ) and accuracy of predictions on the data array for validation ( Acc .).
    Here is a fragment of such a protocol:

    Changing the starting number affects the initial values ​​of the weights of the neural network, which leads to slight differences in the learning process. With a learning rate factor of 0.1, training is completed (when MSE = 0.01 is reached on the test set) in about 300 epochs.
    The accuracy of decisions on the data array for validation is 100% (the program gives the number of the winning neuron, starting from 0 - “0” - the first neuron, ferrous metal; “1” - the second neuron, nonferrous metal):
    0 -> 0
    0 -> 0
    0 -> 0
    ...
    1 -> 1
    1 -> 1
    1 -> 1

    The resulting weights of the neural network after training are saved for later use in a text file nn4md.json in JSON format. By the way, for coding JSON structures on Go it is convenient to use this online tool .
    Since the generally accepted and convenient standard for the storage format of neural network settings has not yet been developed (although there is, of course, NNEF - but for such a simple network it is too IMHO ), I used my own format:

    Testing the neural network
    And now we are testing the trained neural network to recognize new targets ( test dataset ).
    Target number 5 (from ferrous metal) :
    Curve view:

    Value set:
    768 224 96 48 14 0 0 0
    Target No. 6 (from non-ferrous metal) :
    Curve view:

    Value set:
    655 352 254 192 152 124 96 78
    After completion of training, the program waits for data to be entered for testing.
    Check for target number 5:

    Success - "0" - ferrous metal.
    And now let's check for target number 6:

    Success - “1” is a non-ferrous metal.
    That turned out to be almost a proof-of-concept .
    Data set files, network weights file and source code are available in the repository on GitHub.

    Also popular now: