Skip to main content
. 2024 Nov 20;13(22):3697. doi: 10.3390/foods13223697
Algorithm 1 Training algorithm for SAE
  • Require: 

    Dateset Data={xn};The number of hidden units Nh; Number of iterations: m

  • Ensure: 

    Optimization results

  •  1.

    Initialize the matrix and randomize the bias.

  •  2.

    Construct gθ1xn=gUhTxn+b // In the encoding process, UhT is the weight matrix between the input layer and the hidden layer, and b is the bias vector generated during encoding.

  •  3.

    Perform forward propagation to reconstruct x¯:hθ2gθ1xn=hUrTgθ1xn+b // Encoding process, where UrT is the decoding matrix between the input layer and the output layer, and b is the bias vector generated during decoding.

  •  4.

    Calculate loss.

  •  5.

    Perform backpropagation to update model parameters.

  •  6.

    Repeat steps 2–5 m times to output the optimization results and use them as feature vectors of the input vectors to extract higher representations in SAE.