Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Caffe] Improve caffe.Net documentation on forwarding #207

Closed
Enet4 opened this issue Apr 26, 2016 · 5 comments
Closed

[Caffe] Improve caffe.Net documentation on forwarding #207

Enet4 opened this issue Apr 26, 2016 · 5 comments

Comments

@Enet4
Copy link

Enet4 commented Apr 26, 2016

I have been trying to use a caffe.Net for classification purposes, and right now I feel that the documentation on the Forward method and its overloads is not clear enough. All of my efforts so far have either resulted in failed assertions or JVM crashes. Ignoring loss-providing variants, this is what the documentation describes:

BytePointer Forward(BytePointer input_blob_protos) 
caffe.FloatBlobVector   Forward(caffe.FloatBlobVector bottom) 
String  Forward(String input_blob_protos) 

The string-based overload is particularly confusing. It would seem to be the name of the input layer to start forwarding from, but this results in an error: "net.cpp:618] Check failed: blob_proto_vec.blobs_size() == net_input_blobs.size() (0 vs. 1) Incorrect input size."_
The API does not seem to reflect neither of the Python and native APIs either:

def _Net_forward(self, blobs=None, start=None, end=None, **kwargs):
    """
    Forward pass: prepare inputs and run the net forward.

    Parameters
    ----------
    blobs : list of blobs to return in addition to output blobs.
    kwargs : Keys are input blob names and values are blob ndarrays.
             For formatting inputs for Caffe, see Net.preprocess().
             If None, input is taken from data layers.
    start : optional name of layer at which to begin the forward pass
    end : optional name of layer at which to finish the forward pass
          (inclusive)

    Returns
    -------
    outs : {blob name: blob ndarray} dict.
    """
/**     Run Forward and return the result. */
const vector< Blob< Dtype > * > &   Forward (Dtype *loss=NULL)

Setting the input layer's data (with #set_cpu_data(FloatBlob)) and calling ForwardPrefilled() seems to proceed peacefully, but not only is it deprecated in the original project, but I'm also observing some inconsistencies in the outcome that I cannot tell whether they relate to an improper use of the API or not.

Could someone enlighten me on this matter and improve this sub-project's apidocs on the way?

@saudet
Copy link
Member

saudet commented Apr 28, 2016

Where is that native function? I can't seem to find it in rc3:
https://github.com/BVLC/caffe/blob/rc3/include/caffe/net.hpp

@Enet4
Copy link
Author

Enet4 commented May 2, 2016

Where is that native function? I can't seem to find it in rc3

Well, it appears that I was looking at a more recent header file. It does seem to make a bit more sense with the intended version. Still, couldn't the description of each method be copied to the Java files?

It also appears that I'm having some issues with the outcome of forwarding, now that I understand the API, but that ought to be handled elsewhere.

@saudet
Copy link
Member

saudet commented May 2, 2016 via email

@Enet4
Copy link
Author

Enet4 commented May 2, 2016

You are right, the comments are there, my IDE simply didn't take them. Allow me to close this issue, then. Thank you for the help.

@Enet4 Enet4 closed this as completed May 2, 2016
@saudet
Copy link
Member

saudet commented May 2, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants