Skip to main content
. 2025 Aug 6;25(15):4845. doi: 10.3390/s25154845
Algorithm 1 CNN-based IoT attack detection
Require: Dataset D={X,y}, learning rate η0, batch size B, epochs E, folds K
Ensure: Trained model M, results R
 1: Normalize features: x=xxminxmaxxmin,xX
 2: Initialize model weights W,bN(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:     (Xtrainres,ytrainres)SMOTE(Xtrain,ytrain)
 7:     for e=1 to E do
 8:         Shuffle(Xtrainres,ytrainres)
 9:         for all Bi=(XB,yB)(Xtrainres,ytrainres) do
 10:            Z=WXB+b
 11:            Z^=Zμσ2+ϵ
 12:            Z˜=Dropout(Z^,p)
 13:            y^=eZ˜eZ˜
 14:            L=i=1Nyilog(y^i)
 15:            WWηLW, bbηLb
 16:         end for
 17:         ηη0×λeE
 18:         ReEvaluate(M,Xtest,ytest)
 19:         if EarlyStopping(Re) then
 20:              Break
 21:         end if
 22:     end for
 23:     Append Re to R
 24: end for
 25: return M,R