Lei Xun
Lei Xun

Reputation: 21

Does machine learning framework caffe support different data type precisions?

I am currently playing with the CaffeNet C++ image classification example. By default, this example using float. And here were the results I got:

--cat--
Classification time: 0.8267 seconds
0.3134 - "n02123045 tabby, tabby cat"
0.2380 - "n02123159 tiger cat"
0.1235 - "n02124075 Egyptian cat"
0.1003 - "n02119022 red fox, Vulpes vulpes"
0.0715 - "n02127052 lynx, catamount"

--dog--
Classification time: 0.8259 seconds
0.4228 - "n02106662 German shepherd, German shepherd dog, German police dog, alsatian"
0.1344 - "n02109961 Eskimo dog, husky"
0.0914 - "n02091467 Norwegian elkhound, elkhound"
0.0642 - "n02110063 malamute, malemute, Alaskan malamute"
0.0532 - "n02110185 Siberian husky"

After I changed every float to double in classification.cpp. I was hoping I could get similar accuracy with longer computation time. However, I did get longer computation time, but it seems the network no longer works since the accuracy does not look right.

--cat--
Classification time: 1.0368 seconds
0.0015 - "n04435653 tile roof"
0.0015 - "n04209239 shower curtain"
0.0014 - "n03530642 honeycomb"
0.0014 - "n03729826 matchstick"
0.0014 - "n04033901 quill, quill pen"

--dog--
Classification time: 1.0506 seconds
0.0015 - "n04435653 tile roof"
0.0015 - "n04209239 shower curtain"
0.0014 - "n03530642 honeycomb"
0.0014 - "n03729826 matchstick"
0.0014 - "n04033901 quill, quill pen"

I am wondering does Caffe framework support different data type precisions at all? Is that because the network was trained by using float, so it won't work with other data type precisions?

Thanks.

Upvotes: 1

Views: 64

Answers (1)

Shai
Shai

Reputation: 114876

The mean file and the trained parameter you are using in the tutorial are stored in single precision values. Changing float to double in the program does not change the stored values, thus trying to read stored single-precision values as double-precision results with you reading "garbage". You'll have to manually convert the files to double precision values

Upvotes: 2

Related Questions