Skip to content Skip to sidebar Skip to footer

Predict_generator And Class Labels

I am using ImageDataGenerator to generate new augmented images and extract bottleneck features from pretrained model but most of the tutorial I see on keras samples same no of tr

Solution 1:

If you're using predict, normally you simply don't want Y, because Y will be the result of the prediction. (You're not training, so you don't need the true labels)

But you can do it yourself:

bottleneck = []
labels = []
for i inrange(2 * nb_train_samples // batch_size):
    x, y = next(train_generator)

    bottleneck.append(model.predict(x))
    labels.append(y) 

bottleneck = np.concatenate(bottleneck)
labels = np.concatenate(labels)

If you want it with indexing (if your generator supports that):

#...for epoch inrange(2):
    for i inrange(nb_train_samples // batch_size):
        x,y = train_generator[i]

        #...

Post a Comment for "Predict_generator And Class Labels"