2

I am trying to train a CNN in caffe. I wanted to do a lot of data augmentation, so I'm using a "Python" layer for input, as suggested here.

However, I see from the log that Caffe is using the datatype float32 for all my data. This is really wasteful, because I'm only dealing with 8-bit integers. Is there a way to tell caffe to use dtype='uint8'?

I have tried to typecast the data while setting the top:

top[0].data[...] = someArray.astype(np.uint8, copy=False)

but this doesn't work.

Any suggestions?

Community
  • 1
  • 1
gunner
  • 237
  • 2
  • 7

1 Answers1

3

AFAIK, caffe is currently compiled to support only float32 or float64. I suppose lmdb/leveldb data can be stored in uint8 format, but caffe converts it internally to float32 upon reading.
The fact that your input data is uint8 does not mean the entire processing remains this way, at the first convolution/InnerProduct layer, data is multiplied with float numbers and can no longer be guaranteed to remain uint8.
So, I suppose you should put up with the little space waste at the input layer and give up the conversion to uint8.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • 1
    Ok I guess you're right, I would anyway make savings only in the input layer, it's totally not worth the effort. Sorry I can't upvote, I don't have enough reputation. :) – gunner May 29 '16 at 19:54