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

How to get y_true from the generator? #34

Open
GuilhermeCunha opened this issue Aug 20, 2020 · 2 comments
Open

How to get y_true from the generator? #34

GuilhermeCunha opened this issue Aug 20, 2020 · 2 comments

Comments

@GuilhermeCunha
Copy link

How to get y_true from the generator?

my_generator.classes return only the names of the classes, not the y_true.

@SarfarazHabib
Copy link

I have exactly the same question.. I am using this for regression on video based dataset. So i also want to have the y_true values for each frame of my video. How can i get that from the generator ??

@pncanas333
Copy link

pncanas333 commented Sep 8, 2020

Hello,
Not sure if this is the best way to do it but is working for me (at least until I find it doesn't).
My x_gen var is the generator of my test split.
BATCH_SIZE var is the batch size (obviously) that I used when creating the generator, as an argument.

#Get labels
y_test = []
for x in range(x_gen.__len__()):
    #position [1] for labels
    batch = x_gen.__getitem__(x)[1]
    for y in range(BATCH_SIZE):
        y_test.append(batch[y])
#Get labels indices
y_test = np.argmax(y_test, axis=1)

(if there is something wrong, please let me know hehe )
Hope it helps :)

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

3 participants