Ifi6057w11: erinevus redaktsioonide vahel
Mine navigeerimisribale
Mine otsikasti
Uus lehekülg: '= 11. Nädal = ''Perceptron''. Närvivõrgud. ''AIMA'' 18.6.3-18.7.4 Lineaarne klassifitseerija Pythonis. Loenguslaidid: PDF' |
|||
| 6. rida: | 6. rida: | ||
Loenguslaidid: [[Media:chapter20b-abbrev.pdf|PDF]] | Loenguslaidid: [[Media:chapter20b-abbrev.pdf|PDF]] | ||
== Harjutustund == | |||
bmp laadimine (paint.net 8-bit grayscale peal VIST töötab) | |||
<pre> | |||
import struct | |||
def load_bmp(fn): | |||
with open(fn, "rb") as f: | |||
header = f.read(54) | |||
offset = header[10:14] | |||
offs = struct.unpack("@L", offset) | |||
f.read(offs[0]-54) | |||
data = list(f.read(28*28)) | |||
inv_data = [] | |||
for i in range(27, -1, -1): | |||
inv_data += data[i*28: (i+1)*28] | |||
return inv_data | |||
</pre> | |||
Redaktsioon: 29. november 2017, kell 15:12
11. Nädal
Perceptron. Närvivõrgud. AIMA 18.6.3-18.7.4
Lineaarne klassifitseerija Pythonis.
Loenguslaidid: PDF
Harjutustund
bmp laadimine (paint.net 8-bit grayscale peal VIST töötab)
import struct
def load_bmp(fn):
with open(fn, "rb") as f:
header = f.read(54)
offset = header[10:14]
offs = struct.unpack("@L", offset)
f.read(offs[0]-54)
data = list(f.read(28*28))
inv_data = []
for i in range(27, -1, -1):
inv_data += data[i*28: (i+1)*28]
return inv_data