Git Product home page Git Product logo

Comments (5)

ArnoXf avatar ArnoXf commented on May 22, 2024 2

Using model.predict() works for me to predict some images. If it's helpful for others, this is the code I am using:

from PIL import Image
import numpy as np

img = Image.open("17flowers/jpg/0/image_0006.jpg")
img = img.resize((224, 224), Image.ANTIALIAS)
img = np.asarray(img, dtype="float32")

img2 = Image.open("17flowers/jpg/1/image_0096.jpg")
img2 = img2.resize((224, 224), Image.ANTIALIAS)
img2 = np.asarray(img2, dtype="float32")

imgs = np.asarray([img, img2, img3])

So I create an array with two images for prediction. Then I am building my network and train it.

network = ...

model = tflearn.DNN(network, checkpoint_path='model_alexnet',
                max_checkpoints=1, tensorboard_verbose=0)
model.fit(X, Y, n_epoch=100, validation_set=0.1, shuffle=True,
      show_metric=True, batch_size=32, snapshot_step=400,
      snapshot_epoch=False, run_id='alexnet_oxflowers17')

And make a prediction of the two images I loaded in the beginning:

results = model.predict(imgs)
print(np.argmax(results[0]))
print(np.amax(results[0]))
print(np.argmax(results[1]))
print(np.amax(results[1]))

At the moment, the model predicts 1 of 2 or 1 of 3 images right, depending on the images loaded. I will have to train longer to get better results, my network was at an accuracy of ~70% when I got those prediction results.

Thanks for your help @aymericdamien !

from tflearn.

TrinhNC avatar TrinhNC commented on May 22, 2024 1

tensorflow.python.framework.errors.ResourceExhaustedError: OOM when allocating tensor with shape[12544,4096]
How did you fix this problem? I encounter this while training AlexNet but I don't know how to fix it.

from tflearn.

aliyasineser avatar aliyasineser commented on May 22, 2024 1

I tried to train alexnet and I got ResourceExhaustedError also. Can anyone help?
GPU: GTX970M with 3GB memory

from tflearn.

aymericdamien avatar aymericdamien commented on May 22, 2024

Actually, there is not evaluate method available now, the one available for DNN model (.evaluate()) has issue, but it should be fix soon.
The only way now would be to use model.predict(...) to predict all your data per batch, and loop over all your test set and calculate accuracy by yourself.

from tflearn.

aymericdamien avatar aymericdamien commented on May 22, 2024

Nice! Note that this dataset is quite small, so it may not be very accurate.
I will add a .evaluate() method for DNN model class, so it will be easy to evaluate a model on any test set.

from tflearn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.