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

Multilabel classification example #11

Open
SCGT496 opened this issue Dec 2, 2016 · 0 comments
Open

Multilabel classification example #11

SCGT496 opened this issue Dec 2, 2016 · 0 comments

Comments

@SCGT496
Copy link

SCGT496 commented Dec 2, 2016

Would it be possible to also include an example of how to create the TFRecord with multiple labels? I've been working on this, but am stuck--not sure if I'm not interpreting the example incorrectly or what the issue is.

In def convert_to, I've changed 'label': _int64_feature(int(labels[index])) to 'label': labels[index,:], where labels is an array of n by 5--n examples with 5 different labels representing 5 different attributes of a possible image. To create the labels array, I use:

labels[i,:] = [_int64_feature(int(l1)), _int64_feature(int(l2)), _int64_feature(int(l3)), _int64_feature(int(l4)), _int64_feature(int(l5))]

where I loop through each line of my text file, parse it for the 5 specific numbers I need (read in as strings), cast them as ints, and then pass them to the _int64_feature function.

However, I get errors with only _int64_feature(int(l5)), where it says that TypeError: float() argument must be a string or a number. When I wasn't getting that error, using the convert_to function led to this error: TypeError: Parameter to MergeFrom() must be instance of same class: expected Feature got ndarray.

Apologies if this isn't the correct place to ask this question, I just figured that it'd be helpful for anyone else who's working on a similar thing to be able to refer to this issue to resolve their errors as well.

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

1 participant