Skip to main content
. 2025 Aug 6;25(15):4845. doi: 10.3390/s25154845
Algorithm 2 DNN-based IoT attack detection
Require: Dataset D={X,y}, learning rate η0, batch size B, epochs E, learning decay λ, folds K
Ensure: Trained model M, results R
 1: Normalize features: x′=x−xminxmax−xmin,∀x∈X
 2: Initialize weights W,b∼N(0,σ2)
 3: Initialize result set R←∅
 4: F← Stratified K-fold split on (X,y)
 5: for all (Xtrain,ytrain,Xtest,ytest)∈F do
 6:     Apply SMOTE: (Xtrainres,ytrainres)←SMOTE(Xtrain,ytrain)
 7:     η←η0
 8:     for e=1 to E do
 9:         Shuffle(Xtrainres,ytrainres)
 10:         for all Bi=(XB,yB)⊂(Xtrainres,ytrainres) do
 11:              Z=WXB+b
 12:              A=max(0,Z)
 13:              A˜=Dropout(A,p)
 14:              y^=Softmax(A˜)
 15:              L=−∑i=1Nyilog(y^i)
 16:              W←W−η∂L∂W,b←b−η∂L∂b
 17:         end for
 18:         η←η0×λeE
 19:         Re←Evaluate(M,Xtest,ytest)
 20:         if EarlyStopping(Re) then
 21:              Break
 22:         end if
 23:     end for
 24:     Append Re to R
 25: end for
 26: return M,R