Array of floats as input in C++

23 views
Skip to first unread message

Qww

unread,
Jul 17, 2017, 11:14:20 PM7/17/17
to Caffe Users
Hi everyone,

I currently have an array of floats that I would like to use as my input for inference using the Caffe C++ API.
What is the right input format and how should I go about converting my array into that input format?

Thank you!

Atena Nguyen

unread,
Jul 18, 2017, 11:12:26 AM7/18/17
to Caffe Users
You should define "memory data" as you input layer. 
Please check out the example of C++ interface with MNIST data from memory. Note that you might need to change some code since author written in the old version of Caffe. 

link: https://github.com/initialneil/caffe-vs2013

Vào 12:14:20 UTC+9 Thứ Ba, ngày 18 tháng 7 năm 2017, Qww đã viết:

Thomio Watanabe

unread,
Jul 18, 2017, 11:26:13 AM7/18/17
to Caffe Users
1 - Get (a pointer to) the blob
2 - Get the number of elements in the blob
3 - Copy your array to the blob

1
    shared_ptr<Blob<float> > blob_ptr = caffeNet->blob_by_name( blob_name );
    float *blob_content = blob_ptr->mutable_cpu_data();
2
    const unsigned input_size = blob_ptr->count();
3
    copy( input_ptr, input_ptr + input_size, blob_content );


Maybe, caffe has already a built-in function for this...
If anyone knows, pls tell me.
Reply all
Reply to author
Forward
0 new messages