Why do i have to convert "uint8" into "float32"
Asked Answered
P

2

5

I just started looking into deep learning and started to build a CNN with Keras.

So I've noticed that oftentimes when the Dataset MNIST is used, after importing the images, they are getting converted to float32-Datatype.

So my question is, why is that the case? It seems like it should work fine with uint8-Data. What am I missing here? Why is float32 needed?

Pentstemon answered 30/1, 2020 at 12:45 Comment(1)
You want derivatives and small steps, right? Although you can have source data in uint8, the computer needs similar types to perform mathematical operationsJarvis
P
12

Well the reason is simple, the whole math for neural networks is continuous, not discrete, and this is best approximated with floating point numbers. The inputs, outputs, and weights of a neural network are continuous numbers.

If you had integer outputs, they will still be converted to floating point at some point in the pipeline, in order to have compatible types where operations can be made. This might happen explicitly or implicitly, its better to be explicit about types.

In some frameworks you might get errors if you do not cast the inputs to the expected types.

Piggyback answered 30/1, 2020 at 13:6 Comment(0)
B
0

The answer is:

We should perform a lot of data augmentation and training as well in CNN. This will lead to a faster training experience!

Bequeath answered 31/1, 2022 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.