Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet441/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   437   438   439   440   441   442   443   444   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

NumPy implementation

With  NumPy  a  lot  of  the  pain  is  removed  from  matrix  manipulations,  and  in  particular

there are fewer explicit loops. In particular, the updateSomap function in the pure Python

implementation becomes just one line in the NumPy version. See

Chapter  24

 for  further

discussion of this implementation, since the code is just a repeat of what is there.

def selfOrganisingMap(inputs, spread, size, steps=1000):




nRows, nCols = size

vecLen = inputs.shape

somap = numpy.random.rand(nRows, nCols, vecLen)

influence = numpy.dstack([spread]*vecLen) # One for each feature

infWidth = (len(influence)-1) // 2

makeMesh = numpy.ix_ # Ugly

for s in range(steps):

decay = numpy.exp(-s/float(steps))

for vector in inputs:

diff = somap-vector

diff2 = diff*diff

dist2 = diff2.sum(axis=2)

index = dist2.argmin()

row = index // nRows

col = index % nRows

rows = [x % nRows for x in range(row-infWidth, row+1+infWidth)]

cols = [y % nCols for y in range(col-infWidth, col+1+infWidth)]

mesh = makeMesh(rows,cols)

somap[mesh] -= diff[mesh] * influence * decay

return somap




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   437   438   439   440   441   442   443   444   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish