Comments (5)
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.
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.
I tried to train alexnet and I got ResourceExhaustedError also. Can anyone help?
GPU: GTX970M with 3GB memory
from tflearn.
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.
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)
- HELLO? ANYBODY HOME? HOT 1
- Syntax warnings due to comparison of literals using is
- Error in TF2.0... Any ideas? HOT 3
- #001 'unicodeescape' code can't decode bytes in position 2-3: truncated \UXXXXXXXX escape HOT 1
- Update required HOT 1
- Not working with tensorflow 2.3.1 HOT 5
- Import error
- ValueError: Cannot feed value of shape (61,) for Tensor 'InputData/X:0', which has shape '(?, 61)' HOT 1
- Examples
- Xception Example model
- def variance_scaling in initializations.py tries to call deprecated class
- LSTM stateful?
- why i got same number with Alexnet ? HOT 1
- Why tflearn disables executing eagerly ? HOT 2
- OSS License compatibility question
- tflearn import issue HOT 5
- Pillow 10 breaks tflearn import HOT 2
- Requesting Review for pull request #1176
- Use github.com/apssouza22/chatflow as a conversational layer. It would enable actual API requests to be carried out from natural language inputs.
- tflearn HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tflearn.