How to increase accuracy?

Tell us what’s happening:
Describe your issue in detail here.

Could anyone give me a hint how to decrease loss and increase accuracy. I am entering similar values to others, but my values are much worse.
And it is also giving me some errors:

ValueError                                Traceback (most recent call last)
<ipython-input-116-ab192aeb141e> in <module>()
     10 plt.subplot(1, 2, 1)
     11 plt.plot(epochs_range, acc, label='Training Accuracy')
---> 12 plt.plot(epochs_range, val_acc, label='Validation Accuracy')
     13 plt.legend(loc='lower right')
     14 plt.title('Training and Validation Accuracy')

3 frames
/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
    340 
    341         if x.shape[0] != y.shape[0]:
--> 342             raise ValueError(f"x and y must have same first dimension, but "
    343                              f"have shapes {x.shape} and {y.shape}")
    344         if x.ndim > 2 or y.ndim > 2:

ValueError: x and y must have same first dimension, but have shapes (15,) and (1,)

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Cat and Dog Image Classifier

Link to the challenge:

Have you posted this somewhere else? It I’d like to know if you have an answer because I’m having the same problem. I really don’t see what the problem is.

I haven’t posted it somewhere else and I am trying to remember how I fixed this in the end. If I find it I will let you know. I do know that Colab seems a bit whimsical sometimes. It experienced in several projects that restarting from scratch solved issues.

This is the link to my colab site for this project. Maybe we can find some difference with your code?

I think it might have been this part that I added later, that made it work:

history = model.fit(
    x=train_data_gen,
    steps_per_epoch=len(train_data_gen),
    epochs=epochs,
    validation_data=val_data_gen,
    validation_steps=len(test_data_gen),
)

_, acc = model.evaluate(
    train_data_gen,
    steps=len(test_data_gen),
)

print('> %.3f' % (acc * 100.0))

The easiest way to increase accuracy was shown in one of the videos: Use a pre-trained model.

If you are working on your own Tensorflow-model, you might wanna share that with us? Or do you just want some general advice, like “increase depths, width, experiment with activation and loss functions, preprocessing to generate more images…”?

Regarding the error: It’s saying epochs_range has 15 entries and val_acc has one.
So just print them out and see their content - because as before, without seeing any of your code, we cannot give you any advice.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.