A p e- ained con olu ional neu al ne wo k wi h op imized capsule
ne wo ks o ches X- ays COVID-19 diagnosis
Lobna M. AbouEl-Magd
1,5
•Ash a Da wish
2,5
•Vacla Snasel
3
•Aboul Ella Hassanien
4,5
Recei ed: 19 Decembe 2021 / Re ised: 22 June 2022 / Accep ed: 3 Augus 2022
The Au ho (s) 2022
Abs ac
Co ona i us disease (COVID-19) is apidly sp eading wo ldwide. Recen s udies show ha adiological images con ain
accu a e da a o de ec ing he co ona i us. This pape p oposes a p e- ained con olu ional neu al ne wo k (VGG16) wi h
Capsule Neu al Ne wo ks (CapsNe ) o de ec COVID-19 wi h unbalanced da a se s. The CapsNe is p oposed due o i s
abili y o de ine ea u es such as pe spec i e, o ien a ion, and size. Syn he ic Mino i y O e -sampling Technique (SMOTE)
was employed o ensu e ha new samples we e gene a ed close o he sample cen e , a oiding he p oduc ion o ou lie s o
changes in da a dis ibu ion. As he esul s may change by changing capsule ne wo k pa ame e s (Capsule dimensionali y
and ou ing numbe ), he Gaussian op imiza ion me hod has been used o op imize hese pa ame e s. Fou expe imen s
ha e been done, (1) CapsNe wi h he unbalanced da a se s, (2) CapsNe wi h balanced da a se s based on class weigh , (3)
CapsNe wi h balanced da a se s based on SMOTE, and (4) CapsNe hype pa ame e s op imiza ion wi h balanced da a se s
based on SMOTE. The pe o mance has imp o ed and achie ed an accu acy a e o 96.58% and an F1- sco e o 97.08%, a
compe i i e op imized model compa ed o o he ela ed models.
Keywo ds COVID-19 Co ona i us Con olu ion neu al ne wo ks Capsule Neu al Ne wo ks VGG16
Gaussian op imiza ion me hod
1 In oduc ion
Co ona i us (COVID-19), which o igina ed in Decembe
2019 a Wuhan P o ince o he People’s Republic o
China, p esen s a se e e and deadly h ea o heal h
wo ldwide. COVID-19 has in ec ed mo e han 8,963,350
people in 188 coun ies, and he agg ega e o people who
died is inc easing [1]. The e a e se e al medical ways o
diagnosing COVID-19. Ches adiog aphy is he p e e ed
imaging me hod o people in ec ed wi h COVID-19
because i is easily accessible, cheap, and easy o clean and
disin ec [2]. The mos common adiog aphic indings a e
he ai spaces’ opaci y, desc ibed as a usion, o , less
commonly, he Ea h’s glass’s opaci y. The dis ibu ion o
COVID-19 is o en binomial, ci cum e en ial, and in e io
[2].
Con olu ional Neu al Ne wo k (CNN) has impo an
medical image analysis and p ocessing applica ions. The
esul s o CNN show ha i can ansla e image da a o a
p ecise and expec ed ou pu [3,4]. Fu he mo e, Deep
lea ning-based ches X- ays can also diagnose diseases
&Aboul Ella Hassanien
[email p o ec ed]
Lobna M. AbouEl-Magd
[email p o ec ed]
Ash a Da wish
[email p o ec ed]
Vacla Snasel
[email p o ec ed]
1
Compu e Science Depa men , Mis Highe Ins i u e,
Mansou a, Egyp
2
Facul y o Science, Helwan Uni e si y, Helwan, Egyp
3
VSB-Technical Uni e si y o Os a a, Os a a, Czech
Republic
4
Facul y o Compu e s and AI, Cai o Uni e si y, Giza, Egyp
5
Scien i ic Resea ch G oup in Egyp (www.egyp science.ne ),
Giza, Egyp
123
Clus e Compu ing
h ps://doi.o g/10.1007/s10586-022-03703-2(0123456789().,- olV)(0123456789().,- olV)
as e han adi ional me hods. Se e al au ho s used CNN
o medical applica ions in hei esea ch pape s. Fo
ins ance, au ho s in [5] and [6] used he CNN-based
CheXNe model o ches diseases.
Some esea che s use p e- ained CNN. Fo example, in
[7], he au ho s used p e- ained ResNe -50 a chi ec u e
named COVID ResNe . The inpu laye , he g oup o
hidden laye s, and he ou pu laye a e he h ee p ima y
laye s o a CNN. Con olu ional, pooling, ully linked, and
no maliza ion laye s a e also included in he hidden laye s.
When i comes o image- ela ed ope a ions, CNN excels.
They do, howe e , ha e some inhe en limi a ions and
laws. CNN, o example, ails o cap u e ela i e spa ial
and o ien a ion ela ionships and is easily con used by
changes in image o ien a ion o pose. The max-pooling
laye is c i ical because i downsamples he da a and
dec eases he spa ial in o ma ion gi en o he nex laye .
On he o he hand, he max-pooling laye has a disad an-
age o CNN because i canno con ey spa ial hie a chies
ac oss a ious objec s. This law causes in a iance, and he
pose and spa ial.
Al hough CNNs pe o m well in dealing wi h images,
hey s ill ha e a se o sho comings. The agg ega ion
p ocess used in con olu ional neu al ne wo ks su e s om
losing aluable in o ma ion when using agg ega ion laye s.
In addi ion, hey equi e huge amoun s o da a o lea ning.
Laye ing in a CNN educes spa ial esolu ion, and he
ne wo ks’ ou pu ne e changes e en wi h a small amoun
o change in he inpu . I canno be di ec ly ela ed o he
ela ionship o pa s and equi es addi ional componen s.
This is whe e Capsule Ne wo ks comes in o play and
o e comes all he d awbacks o CNN. Capsule ne wo ks
(CapsNe ) can e ch spa ial in o ma ion o o e come
in o ma ion loss in agg ega ions [8].
CapsNe is a no el ype o neu al ne wo k p esen ed in
[9], which in oduced a ‘‘capsule’’ concep . A capsule is a
bunch o neu ons. Each laye in a capsule ne wo k has
se e al capsules. The Capsule’s ou pu s ha e di e en
p ope ies o he same en i y. The adi ional CNN is based
on he ision sys em’s use o he same knowledge a all
loca ions wi hin an image. This is o en accomplished by
linking ea u e de ec o weigh s o make ea u es lea ned in
one loca ion a ailable in o he s. Con olu ional capsules
ex end knowledge sha ing ac oss si es o include he pa -
whole ela ionships ha cha ac e ize he amilia o m.
This is achie ed when a laye ’s posi ion ma ix is mul i-
plied by a ainable iewpoin s a ic ans o ma ion ma ix
ha can lea n o ep esen pa - o- o al ela ionships, cap-
sule o es o he posi ion ma ix o se e al capsules abo e
i in ha laye [10].
The Capsule has hype pa ame e s ha a ec i s algo-
i hm’s complexi y and accu acy o a gi en p oblem [11].
These hype pa ame e s a e he numbe o ou ing and
capsule dimensionali y. Many op imiza ion algo i hms can
be used o ge op imal hype pa ame e alues.
This pape p oposes a new model ha uses p e- ained
CNN VGG16 wi h a CapsNe o de ec COVID-19. The
accu acy o he p oposed model is enhanced by using he
Gaussian op imiza ion p ocess o une he hype pa ame e s
o he Capsule neu al ne wo ks (CapsNe ).
The main con ibu ion o his pape is summa ized as
ollows.
•Handling he balancing and he small numbe o images
on he benchma k da abase as wo p oblems may
impac he de ec ion and classi ica ion esul s
•P e- ained he model is used o deep ea u e ex ac ion
using VGG16 as inpu o he CapsNe .
•De ec ion o COVID-19 de ec ion model based on p e-
ain VGG16 wi h Capsule Ne wo ks
•Applying Gaussian op imiza ion o CapsNe hype pa-
ame e op imiza ion
This pape is o ganized as ollows. Sec ion 2 e iews
ela ed wo ks. Sec ion 3 ocuses on he p elimina ies and
basics, whe eas Sec . 4p esen s he ma e ials and me hods.
Fu he mo e, Sec . 5desc ibes he expe imen al esul s and
analyzes he esul s and pe o mance o he p oposed
model. Finally, Sec . 6has he conclusion and highligh s
u u e wo k.
2 Rela ed wo ks
A i icial in elligence has been used o ecognize and
classi y lung diseases in ecen decades. Resea ch has
a ied be ween image ea u e ex ac ion, sui able image
ecogni ion, and disease iden i ica ion classi ie s. Fo
example, Pa il in [12] classi ied Lung cance based on a
ex u e ea u es ex ac ion and he backp opaga ion neu al
ne wo k. The e ie ed ea u es we e a e age g ey le el,
s anda d de ia ion, smoo hness, he hi d momen , uni o -
mi y, and en opy. Fu he mo e, an accu acy o 83 pe cen
was ob ained. The au ho s used mul ilaye , p obabilis ic,
lea ning ec o quan iza ion, and gene alized eg ession
neu al ne wo ks o achie e a compa a i e ches illness
diagnosis [13]. They demons a ed ha he p obabilis ic
neu al ne wo k pe o med be e .
The sp ead o he co ona i us has been a g ea dange
since i s ou b eak in Wuhan in Decembe 2019. This i us
has a eal wo ldwide disas ous impac , as he numbe o
dea hs eached 2,624,677 and con i med cases 118,268,575
in abou 223 coun ies, acco ding o he epo s o he
Wo ld Heal h O ganiza ion on Ma ch 12, 2021 [14]. This
mo i a ed many esea che s o iden i y his d eaded disease
and limi i s sp ead.
Clus e Compu ing
123
Pe ei a e al. in [15] c ea ed RYDLS-20, a da abase o
CXR images o pneumonia and heal hy lungs. They used
mul iclass and hie a chical classi ica ion and esampling
algo i hms o deal wi h an unbalanced da a se . They
compa e and use di e en ea u e ex ac ion algo i hms o
ex ac ing ea u es om he image, such as bina ized s a-
is ical image ea u es (BSIF), local bina y pa e ns (LBP),
local di ec ional numbe pa e n (LDN), elonga ed quina y
pa e ns (EQP), local phase quan i y (LPQ), and Basic
O ien ed Image Fea u es OBIF. The sugges ed echnique
yielded an a e age F1 sco e o 0.65 using a mul iclass
app oach in he hie a chical classi ica ion scena io and an
F1 sco e o 0.89 o COVID-19 iden i ica ion.
Tej Bahadu Chand a e al. [16] employed a a ie y o
ways o ex ac ea u es om images and hen used bina y
g ey wol op imiza ion o selec he bes ones. Thei s udy
pe o ms classi ica ion in wo phases. The i s phase dis-
inguishes be ween no mal and abno mal ches images. The
second phase (phase II) dis inguishes pneumonia and
Co id-19 ches images. Addi ionally, he o ing-based
classi ie ensemble is used o classi ica ion. The majo i y
o e-based classi ie ensemble in phase (I) ga e 98.062%
accu acy and 98.55 o he F1 sco e, and phase II ga e
91.32% accu acy and 91.73 o he F1 sco e. Fu he mo e,
he majo i y o e-based classi ie ensemble ga e an o e all
accu acy o 93.41%.
CNN has been used in many ypes o esea ch o
de ec ing he COVID-19. Fo example, Asmaa Abbas e al.
[17] used a deep CNN called decompose, ans e , and
compose o de ec COVID-19 X- ay pic u es (DeT aC).
They demons a ed DeT aC’s compe ence in de ec ing
COVID-19 wi h a 93.1% accu acy. Any anomalies in he
pic u e da ase a e deal wi h u ilizing a class decomposi-
ion app oach by DeT aC.
O. M. Elzeki e al. [18] p oposed a CXR COVID Ne -
wo k (CXRVN) ne wo k. CXRVN is a compac a chi ec-
u e based on a single ully-connec ed node. The CXRVN
uses Mini-ba ch g adien descen and Adam op imize . The
au ho s used h ee da ase s o es hei model. Da ase -1
comp ises wo class labels and 50 X- ay images, and he
es accu acy was 92.85%. Addi ionally, Da ase -2 com-
p ises wo class labels and 455 X- ay images wi h 96.70%
accu acy. Fu he mo e, Da ase -3 comp ises h ee class
labels and 603 X- ay images, and he accu acy was
91.70%. Mo eo e , hey used gene a i e ad e sa ial ne -
wo ks (GAN) augmen a ion, gi ing 96.7% accu acy in
Da ase -2 o wo classes and 93.07% in Da ase -3 o h ee
classes. The a e age accu acy eached 94.5%.
M.Nou e al. [19] used CNN o ex ac ing disc imi-
na i e ea u es and di e en machine lea ning app oaches
o classi ica ion. The hype pa ame e s o hei models
we e op imized using he Bayesian op imiza ion algo i hm.
The suppo ec o machines classi ie ensu ed he mos
e icien esul s wi h 98.97% accu acy and 96.72% F1-
sco e.
Some esea che s used p e- ain CNN models and
ans e ed lea ning o COVID-19 de ec ion o ge mo e
accu a e esul s. M. M. Rahaman e al. used deep ans e
lea ning o compa e 15 p e- ained CNN models. The
VGG19 had an F1 sco e o 0.90 and an accu acy o 89.3%
[20].
A un Sha ma e al. [21] Used ans e lea ning o build
AI-based classi ica ion models, CXR pic u es depic ing he
in es iga ed diseases may be accu a ely classi ied. They
pe o med 25 di e en augmen a ions on he o iginal pic-
u es o inc ease he da ase . They hen used a ans e
lea ning me hod o ain and es hei models. A e
aining 286 images in each o he wo bes models, com-
bining hem p oduced he maximum p edic ion accu acy
o he no mal, COVID, non-COVID, and pneumonia/ u-
be culosis sho s.
Fo bina y (COVID s. No-Findings) and mul iclass
classi ica ion (COVID s. No-Findings s. Pneumonia),
Tulin Oz u k e al.[22] in oduced he Da kNe model.
Bina y classi ica ion accu acy was 98.08%, while mul i-
class classi ica ion accu acy was 87.02% o hei model.
In [23], D. Ezza e al. p oposed an op imized hyb id
CNN. The used CNN a chi ec u e is DenseNe 121, and he
op imiza ion algo i hm is he g a i a ional sea ch algo i hm
(GSA). The GSA is used o de e mine he mos app op ia e
alues o he hype pa ame e s o he DenseNe 121 a chi-
ec u e. Thei accu acy eached 98.38%
In [24], Hossein Abbasimeh e al. sugges ed a me hod
o o ecas COVID-19 ime se ies using h ee deep lea ning
echniques: (1) LSTM, (2) ga ed ecu en uni s, and (3)
CNN. The sugges ed s a egy conside ably inc eases he
pe o mance o LSTM and CNNs in e ms o symme ic
mean absolu e pe cen age e o and oo mean squa e e o
measu emen s.
Table 1shows he ele an wo k on COVID-19 diag-
nosis om ches X- ay adiog aphs; we can see om his
Table ha he pe o mance o he majo i y o he pieces is
poo , especially in mul iclass wo k, excep Nou e al. [19],
whe e he 1-sco e is lowe han he accu acy. As a esul ,
we we e mo i a ed o inc ease he accu acy o mul iclass
classi ica ion by employing a capsule ne wo k, which is
conce ned wi h collec ing he pose and spa ial in e ac ions
be ween image pixels.
3 P elimina ies
3.1 Capsule neu al ne wo ks
CNN is cu en ly used in many applica ions and has shown
sa is ac o y esul s in hese applica ions’ classi ica ion and
Clus e Compu ing
123
p edic ion p ocesses. Howe e , CNN pe o ms poo ly in
ecognizing posi ion, ex u e, and dis o ions o an image
o pa s o an image. This implies ha he CNNs a e
in a ian . The pooling phase in CNN may p oduce
in a iance. CNN’s a e no equi a ian and hus lack
equi alence. Fu he mo e, some images’ ea u es a e los
due o he pooling ope a ion on CNN.
Consequen ly, CNNs a e being supplan ed by capsule
ne wo ks. Unlike CNN, capsules a e equi a ian and con-
sis o a ne wo k o neu ons ha inpu and ou pu ec o s
a he han he scala alues. This capsule p ope y allows
i o lea n he image’s de o ma ions, iewing condi ions,
and ea u es [25,26]. Capsule ne wo ks a e made up o
laye s o capsules. Each Capsule comp ises a collec ion o
neu ons whose ou pu ep esen s a dis inc aspec o he
same ea u e. CapsNe was in oduced in [9], whe e he
Capsule is de ined as a se o neu ons wi h ac i i y ec o s
ep esen ing ins an ia ion pa ame e s and he leng h o he
ec o , signi ying he likelihood o he ea u e exis ing. The
CapsNe model used in his pape consis s o 3 main suc-
cessi e laye s, as shown in Fig. 1, including he con olu-
ional laye , p ima y capsule (PC), and class capsule laye s
named digi caps laye [9].
The i s laye (con olu ional laye ) is esponsible o
image ea u e ex ac ion, whe e he image’s pixel is con-
e ed o spa ial in o ma ion. The ou pu o he con olu ion
laye en e s he PC laye . The PC laye may ac as hough
he ende ing p ocess was e e sed. An image’s in o ma-
ion can be di ided in o nume ous uni s unde se e al
channels o gene a e a ec o o ese ed spa ial da a o
each uni . I eaches he class capsule’s nex laye o
neu ons. This inno a i e ne wo k s uc u e eplaces he
pooling laye in a no mal con olu ional ne wo k, educing
in o ma ion loss signi ican ly [9,27,28].
An o e iew o how he capsule ne wo k wo ks is as
ollows. Laye l, each Capsule ihas an ac i i y ec o o
i
ha encodes spa ial in o ma ion in ins an ia ion pa ame-
e s. The i h lowe -le el capsule’s ou pu ec o o
i
is sup-
plied o all capsules in he nex laye l ?1. A laye l ?1,
he j h Capsule will ecei e o
i
and loca e i s p oduc using
he weigh ma ix W
ij
. The ^
o
j|i
ec o ans o ms Capsule j
a le el l ?1 by Capsule ia le el l. ^
o
j|i
is a PC’s p e-
dic ion ec o showing how much he p ima y Capsule i
con ibu es o class j.
^
oji
j¼Wijoið1Þ
Table 1 Summa y and analysis o he ela ed wo ks
Pape Me hod Classes Pe o mance
Rodol
M.Pe ei a
e al. [15]
Use di e en ea u e ex ac ion algo i hms Mul iclass The mul iclass F1-sco e was 0.65,
and he hie a chical classi ica ion
F1-sco e was 0.89
M.
M. Rahaman
e al. [20]
VGG19 Mul iclass Accu acy was 89.3%, and F1 sco e
was 0.90
Asmaa Abbas
e al.[17]
Deep CNN Bina y class Accu acy was93.1%
Tej Bahadu
Chand a e al.
[16]
Used di e en ea u e ex ac ion
echniques and used bina y g ay wol
op imiza ion o ea u e selec ion. Also,
used o ing-based classi ie ensemble is
used
Dis inguishes be ween no mal and
abno mal ches images and
dis inguishes be ween pneumonia, and
he Co id-19 ches
Phase (I) ga e 98.062% accu acy and
98.55 o he F1-sco e, and phase II
ga e 91.32% accu acy and 91.73
o F1 sco e
The majo i y o e-based classi ie
ensemble ga e an o e all accu acy
o 93.41%
O. M. Elzeki
e al. [18]
p oposed a ne wo k a chi ec u e called
CXR COVID
Mul iclass - Accu acy was 96.7%
- Accu acy was 93.070%
M.Nou e al.
[19]
Sugges ed model based on CNN Mul iclass Accu acy was 98.97% and an F1-
sco e was 96.72%
Tulin Oz u k
e al.[22]
p oposed he Da kNe model bina y classi ica ion mul iclass
classi ica ion
The bina y class accu acy was
98.88%, while he mul iclass
accu acy was 87.02%
Dalia [23] DenseNe 121 The g a i a ional sea ch algo i hm is
used o de e mine he bes alues o
he hype pa ame e s o he
DenseNe 121 a chi ec u e
Accu acy 95%
Clus e Compu ing
123
One main capsule i’s p edic ion o class capsule j is
made by mul iplying i s p edic ion ec o by i s coupling
coe icien , which measu es he deg ee o ag eemen
be ween he wo caps. They a e linked as long as he e is a
signi ican deg ee o ag eemen be ween he wo capsules.
As a esul , he coupling coe icien will inc ease a he
han dec ease as would occu i he opposi e occu ed.
To ind he squashing unc ion candida es, a weigh ed
sum (ws
j
) o all hese indi idual PC p edic ions o he
class capsule j is p oduced (q
j
).
wsj¼XN
i¼1cij ^
oji
jð2Þ
qj¼wsj
2
1þwsj
2
wsj
wsj
ð3Þ
cij ¼expðbijÞ
PkexpðbijÞð4Þ
The squashing unc ion, like a likelihood, assu es ha he
leng h o he ou pu om he Capsule is be ween 0 and 1. The
q
j
om one capsule laye is passed on o he nex capsule
laye , whe e i is ea ed he same way as be o e. The c
ij
coupling coe icien ensu es ha he le el l p edic ion o I is
linked o he laye l ?1 p edic ion o j. The do p oduc o o
ˆ
j|i and qj is ob ained du ing each cycle, and c
ij
is upda ed. The
ec o alues o each Capsule may be hough o as a com-
bina ion o wo numbe s: a p obabili y indica ing he p es-
ence o he ea u e encapsula ed by he Capsule and a se o
ins an ia ion pa ame e s ha can be used o explain laye
consis ency. The e m ‘‘ ele an pa h by ag eemen ’’ comes
om he ac ha when lowe -le el capsules ag ee on a
highe -le el laye capsule, hey ‘‘cons uc a pa -whole’’
ela ionship demons a ing pa h ele ance. Dynamic ou -
ing-by-ag eemen is he name o his app oach [9,10,25].
Capsule ne wo ks su e om expensi e compu a ional
me hods, ye nume ous ou ing laye s inc ease aining cos s
and in e ence ime because o he complexi y o he ne wo k
[29]. Resea che s in [24] ha e, on he o he hand, demon-
s a ed ha he p edic ion ime is signi ican ly sho e han
ha o o he deep lea ning echniques. In his esea ch, he
op imiza ion s a egy ocuses on he numbe o ou ing o ge
high pe o mance wi h minimal complexi y.
3.2 VGG16 a chi ec u e
VGG16 is a CNN model in oduced in [30]. VGG-16
includes 16 laye s, 13 o which a e con olu ional and h ee
o which a e ully linked. Fi e blocks comp ise he con-
olu ional laye s. The model uses only il e s o size 3 93
wi h one s ide o con olu ions and 2 92 pooling wi h
wo s ides in all laye s, esul ing in a homogenous and
smoo h a chi ec u e. The p e- ained VGG16 model can
classi y images in o 1000 objec ca ego ies wi h million
images. I go an accu acy o abou 92.7% in he accu acy
es o he ImageNe da ase —VGG16 imp o es o he
CNN models like AlexNe . The NVIDIA Ti an Black GPU
has been used o aining he VGG16 [30]. Figu e 2shows
he VGG16 a chi ec u e.
3.3 Gaussian op imiza ion algo i hm
The Gaussian p ocess (GP) is speci ied by i s mean and
co a iance unc ions. I can be w i en as:
FðxÞgpðmðkÞ;Kðk;kÞÞ ð5Þ
whe e m(k) deno es mean, and K deno es co a iance [31].
The Bayesian model is a simple example o a GP, and he
Bayesian op imiza ion me hod is one o he gene al op i-
miza ion me hods; he op imiza ion me hod is an i e a i e
algo i hm. A p obabilis ic su oga e model elemen o he
Gaussian op imiza ion app oach and an acquisi ion unc ion
de e mining he nex poin o be assessed a e included. The
su oga e model i s all a ge unc ion obse a ions hus a
in each cycle. The assemblage unc ion es ima es he u ili y
o candida e nodes using he p obabilis ic model’s p edic ion
dis ibu ion. Ra he han assessing cos ly e o s, he
impo ance o acquisi ions is calcula ing and op imizing
hem [26,31]. The expec ed imp o emen (EI) is based on
Eq. (6) and is he acquisi ion unc ion.
Fig. 1 Capsule ne wo k
a chi ec u e
Clus e Compu ing
123
E[I(k)] = E[max( min Y, 0)] ð6Þ
whe e (EI) is compu ed in he closed- o m i he p edic ion
o he Model Y a con igu a ion kacco ding o a no mal
dis ibu ion is de ined using Eq. (7).
E½IðkÞ ¼ ð min lðkÞÞU min lðkÞ
þ / min lðkÞ
ð7Þ
whe e u() is he s anda d no mal densi y, U()s he s an-
da d no mal dis ibu ion unc ion, and
min
is he bes -ob-
se ed alue.
3.4 Syn he ic mino i y o e -sampling echnique
(SMOTE)
Machine lea ning algo i hms a e usually e alua ed based on
hei p edic i e accu acy. The da ase is imbalanced i he
classes a e no oughly equally ep esen ed. When he da a is
une en, his is ine ec i e. The da a-le el echnique aims o
ebalance he mino i y and majo i y classes by modi ying he
da a. This can be done by ei he emo ing some examples
om he majo i y class (unde -sampling) o inc easing he
numbe o cases om he mino i y class (o e -sampling)
(o e -sampling). SMOTE is an o e -sampling me hod ha
uses ‘‘syn he ic’’ ins ances a he han eplacemen o e -
sampling o o e -sample he mino i y class [32].
4 The p oposed p e- ained CNN
wi h op imized CapsNe o ches X-Ray
COVID-19 diagnoses
The p oposed COVID-19 de ec ion model mainly includes
ou phases, as shown in Fig. 3: da a p ep ocessing, p e-
ained, classi ica ion and op imiza ion, and e alua ion
phases. Each o hese phases is explained in he ollowing
subsec ions.
4.1 Da a p epa a ion phase
O e i ing occu s when a ne wo k lea ns a unc ion wi h a
high a iance o model he aining da a success ully. This
phase implemen ed h ee key s eps: spli ing da a in o
aining and es ing se s, da a augmen a ions, and balancing
he da ase . Due o i s no el y, we disco e ed wo issues
wi h he en i e da ase . The i s p oblem is ha he e a e
ew da a poin s, and he second is ha he da a is unbal-
anced. The medical da ase only con ains a ew pho os,
whe eas deep lea ning algo i hms equi e a la ge amoun o
da a o a oid o e i ing.
The e a e many ways and echniques o a oid o e i ing
( aised om he small da ase ); one o hem and he mos
used is da a augmen a ion. We used he image da a aug-
men a ion me hods, such as o a ing igh wi h 30 deg ees,
le wi h 30 and ?90 deg ees up and ho izon ally abou
Y-axis, and shea in his wo k.
We employ wo app oaches o deal wi h he unbalanced
da ase . The i s one is based on he class weigh based on
cos ly e o s. The cos e o alue will be included in he
p obabili y o each class. The second app oach is using
SMOTE echnique based on o e -sampling. I in ol es
mul iplying selec poin s om he mino i y class o
b oaden hei o igin. Ano he issue in he p ep ocessing
phase is spli ing he da ase in o aining and es ing
da ase s wi h 70% and 30% a ios.
4.2 P e- ained and CapsNe op imiza ion
phases
The aining p ocess is di ided in o he ollowing h ee
s eps.
S ep (1): P e- ain CNN VGG16 A chi ec u e: gene ally,
he elemen a y ea u es can be ex ac ed on CNN. The
elemen a y ea u e may be edges and co ne s. The
ex ac ed ea u es a e agg ega ed in he nex laye s o
de ec highe -o de ea u es. CNN has ano he essen ial
Fig. 2 The a chi ec u e o he
p e- ained VGG16
Clus e Compu ing
123
p ope y; his p ope y sha es weigh s meaning ha simila
ea u e de ec o s a e u ilized o he whole objec . CNN has
many laye s known as ‘‘sub_sampling’’ laye s. The
‘‘sub_sampling’’ laye s depend on he ac ha he ea-
u es’ exac loca ion is use ul and des uc i e since his
da ase ends o a y o di e en images o objec s [33].
T ans e lea ning om a p e- ained model like VGG16
ex ac s he in-dep h ea u es. The image is inpu o he p e-
ained ne wo k, and he ac i a ion alues o di e en
laye s a e s o ed and u ilized as ea u es [34]. The VGG16
consis s o i e blocks ha help ge simila ea u es
ins an ly. So, VGG16 will be used on he ecen new
a chi ec u e called CapsNe in oduced in [9]. Figu e 4
shows he isualiza ion o VGG16 ou pu .
S ep (2): Capsule ne wo k (COVID-caps): The X- ay
image o COID-19 di e s om he no mal image because
i con ains whi e spo s on he lung; also, i di e s om he
i al pneumonia image due o he loca ion, whe eas in
co id-19, hese spo s sp ead a he bo om o he lung mo e,
i.e., he a ea o he spo s con ibu es o iden i ying COVID-
19. Ins ead o neu ons CapsNe is made up o capsules. As
de ined in [35], he Capsule can be a collec ion o neu al
ne wo ks. I could ca y ou complex in e nal calcula ions
on hei inpu s and s o e he esul s in a iny ec o . The
Capsule eco ds he ela i e posi ion o he i em, and i he
objec ’s pose changes, he ou pu ec o o ien a ion also
changes. CapsNe is made up o se e al laye s. The i s
laye is called PCs, consis ing o indi idual capsules ha
each ecei es a small po ion o he ecep i e ield as inpu
and a emp o de e mine he pose o a speci ic pa e n. The
Capsule ou pu is a ec o , and a dynamic ou ing mech-
anism was employed o ensu e ha he esul was sen o
he app op ia e pa en in he laye , which could be
deduced.
The CapsNe a chi ec u e consis s o wo laye s.
(i) The PC laye is he i s laye o he CapsNe ha
ollows he p e- ain model. I is a con olu ional
capsule laye ha con ains 32 channels o con o-
lu ional 10 D capsules. Each PC has en con olu-
ional uni s wi h a (9 99) ke nel, and he numbe
o he s ides is 2.
(ii) COVID-caps capsule laye con ains h ee capsules,
deno ed as ‘‘COVID-caps,’’ and one candida e o
lung disease (COVID-19, i al pneumonia, o
no mal). The COVID capsule laye consis s o 10
capsules, each ep esen ing a pa icula class o he
lung disease da ase wi h h ee. The ini ial dimen-
sion used o hese capsules is 16. Compu ed
Fig. 3 The p oposed COVID-19
p edic ion model using
Op imized CapsNe
Fig. 4 Visualiza ion o VGG16 ou pu
Clus e Compu ing
123
COVID-caps capsules’ ou pu calcula es he p e-
dic ed ou pu ec o s o each p ima y COVID-caps
capsule pai and implemen s he ou e by ag ee-
men algo i hm.
Ma gin loss o lung diseases is he leng h o he
ins an ia ion ou pu ec o ep esen ing he p obabili y o
he espec i e Capsule’s en i y exis ence. Fo e e y dis-
ease_kind Capsule Co, he ma gin loss is sepa a e and is
gi en in Eq. (8). The disease class Co has he mos p o-
longed ec o ou pu i he lung disease is p esen in he
inpu image.
LCo ¼TCo maxð0;m þVCo
kkÞ
2þkð1
TCoÞmaxðð0;VCo
jjjj
m Þ2ð8Þ
The alue o T
Co
is 1 i a lung disease o class Co is
p esen , and in his s udy m
?
= 0.9 and m
-
= 0.1. kis a
egula iza ion pa ame e ha s ops lea ning om sh inking
all lung disease capsules [10].
Figu e 5p esen s he isualiza ion o he CapsNe . The
disease spo s a e isible in Fig. 5a o Coi d-19 disease
and Fig. 5(b) o i al pneumonia.
The accu acy is compu ed as he co ec ly iden i ied
lung disease a io by he o al numbe o lung diseases.
Accu acy = RCo ec iden i ied lung diseases
To al numbe o lung diseases ð9Þ
S ep (3): CapsNe hype pa ame e op imiza ion:
Hype pa ame e op imiza ion is a way o ind a D-
dimension hype pa ame e se ing x ha minimizes he
alida ion loss/e o o he CapsNe lea ned wi h. The
unc ion maps a hype pa ame e choice xo Gcon ig-
u able hype pa ame e s o a CapsNe algo i hm’s alida-
ion e o wi h lea ned pa ame e s [36]. Op imizing , as
shown in Eq. 10, sugges s a solu ion o inding ou he
op imal hype pa ame e s au oma ically:
minx2RG ðx;h;S alÞ
s: :h¼a g min
h ðh;S ainÞð10Þ
Sol ing he p oblem in Eq. (10) is qui e challenging due
o he inc edible complexi y o he unc ion . Whe e S
ain
deno es he aining da ase , and S al ep esen s he ali-
da ion da ase . The lea ning p ocess educes he aining
loss/e o , and he alue o xis in a bounded se . The GP is
one o he Bayesian op imiza ion algo i hms. Bayesian
op imiza ion algo i hms use a cheap p obabilis ic su oga e
model o app oxima e he expensi e e o unc ion. Con-
sequen ly, we use he GP o op imize he hype pa ame e s
o he CapsNe . Algo i hm (1) shows he de ailed s eps o
he COVID-19 CapsNe De ec ion Model.
(a) COVID-19
(b) Vi al pneumonia
Fig. 5 CapsNe isualiza ion.
aCOVID-19. bVi al
pneumonia
Clus e Compu ing
123
5 Expe imen al esul s
The expe imen s we e pe o med using enso low and
Ke as wi h a TPU google COLAB en i onmen .
5.1 Da ase
The COVID-19 Ches X- ay images used in his s udy a e
om he I alian Socie y o Medical and In e en ional
Radiology and a e named he SIRM da ase . The da ase is
hos ed a Kaggle [37] and con ains heal hy ins ances, i al
pneumonia, and COVID-19 pa ien s. I con ains 219 posi-
i e images o COVID-19, 1341 s anda d images, and
1345 images o i al pneumonia. The images a e in
po able ne wo k g aphics ile o ma wi h a 1024 91024
pixels esolu ion. The da ase is no balanced and may need
some e o o balance be o e using he deep lea ning-based
COVID-19 de ec ion. Figu e 6shows samples o he
aining and es ing images o he h ee classes. Panel
Type ( ow-1) illus a es he COVID-19 in ec ed, panel
( ow-2) shows i al pneumonia, and panel ( ow-3) illus-
a es heal hy ins ances.
5.2 E alua ion measu es
The p oposed model capaci y is e alua ed based on he
accu acy (Acc), p ecision (P), ecall (R), and F1 sco e.
Accu acy is he pe cen age o ue p edic ions om all
o ecas s made, calcula ed by Eq. (11), p ecision assesses a
model’s abili y o p edic alues o a speci ic ca ego y
co ec ly, and i is calcula ed using Eq. (12), ecall is cal-
cula ed as he ac ion o co ec ly classi ied posi i e pa -
e ns in Eq. (13). A he same ime, F1 sco e is he
weigh ed a e age o p ecision and ecall calcula ed based
on Eq. (14).
Acc = (TP + TN)/(TP + FP + FN + TN) ð11Þ
P¼TP=ðTP þFPÞð12Þ
Clus e Compu ing
123