Hands-On Deep Learning for Images with TensorFlow


[ 30 ] Turning categories into tensors



Download 5,72 Mb.
Pdf ko'rish
bet15/32
Sana22.12.2022
Hajmi5,72 Mb.
#893820
1   ...   11   12   13   14   15   16   17   18   ...   32
Bog'liq
Hands On Deep Learning for Images

[ 30 ]
Turning categories into tensors
In the previous section, we looked at turning images into tensors for machine learning, and
in this section, we will look at turning the output values, the categories, into tensors for
machine learning.
We will cover output classes, what it means to make a discrete prediction, the concept of
one-hot encoding; and then we'll visualize what one-hot encoding looks like as an image,
and then we'll recap with a data preparation cookbook, which you should use to be able to
deal with all kinds of image data for machine learning.
But for now, let's talk about output. When we're talking about digits, there's 
0
through 
9
, so
there's ten different classes, and not classes in the object-oriented sense, but classes in the
label sense. Now, with these labels being from 
0
to 
9
as individual digits, the predictions
we want to make need to be discrete. It won't do us any good to predict 1.5, there's no such
digit character:
o to 9 predictions
So, for this, we're going to use a data transformation trick. This thing is called one-hot
encoding, and it is where you take an array of label possibilities, in this case, the numbers 
0
through 
9
, and turn them into a kind of bitmap, where each option is encoded as a column,
and only one column is set to 
1
(hence one-hot) for each given data sample:
One-hot encoding


Image Data
Chapter 2
[ 31 ]
Now, looking at both an input digit (here, 
9
), and the output bitmap, where you can see
that the forth index has the ninth bit set, you can see that what we're doing in our data
preparation here is having one image as an input and another image as an output. They just
happen to be encoded as tensors (multidimensional arrays of floating point numbers):
Output bitmap
What we're going to be doing when we create a machine learning algorithm is have the
computer learn or discover a function that transforms the one image (the digit nine) into
another image (the bitmap with one bit set on the ninth column), and that is what we mean
by machine learning. Remember that tensors are just multidimensional arrays, and that the
x and y values are just pixels. We normalize these values, which means we get them from
the range of zero to one so that they are useful in machine learning algorithms. The labels,
or output classes, are just an array of values that we're going to map, and we're going to
encode these with one-hot encoding, which again means only one is hot, or set to one.


Image Data
Chapter 2

Download 5,72 Mb.

Do'stlaringiz bilan baham:
1   ...   11   12   13   14   15   16   17   18   ...   32




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