user10026373
user10026373

Reputation:

Compute accuracy for CNN using TensorFlow and flow_from_directory

I am using flow_from_directory method to feeding data into neural network:

train_generator = train_datagen.flow_from_directory('.../train', target_size=(img_width, img_height), batch_size=32,class_mode='categorical')

Now I want to print (calculate) the training accuracy. When you have splitted training data to y_train and x_train, you use something like this:

training_accuracy = compute_accuracy(y_train, model.predict(x_train))

But I dont have splitted data. How can I do this?

Upvotes: 0

Views: 88

Answers (1)

sugar2code
sugar2code

Reputation: 167

flow_from directory returns a tuple of (x, y) where x is a numpy array containing a batch of images with shape (batch_size, *target_size, channels) and y is a numpy array of corresponding labels.

So your x_train would be train_generator[0] and y_train is train_generator[1]

Upvotes: 0

Related Questions