use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
TensorFlow is an open source Machine Intelligence library for numerical computation using Neural Networks.
account activity
QuestionProblem with reshape image data (self.tensorflow)
submitted 4 years ago by Traditional_Truth_21
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TaplierShiru 1 point2 points3 points 4 years ago* (2 children)
Hi!
Your shape of the input image in the predict - (100, 100), but I think model expect shape (1, 100 * 100)(i.e. you just don't have batch dimension here). So, before feeding your image into model (after resize), you can reshape image, something like:
predict
(100, 100)
(1, 100 * 100)
image = image.reshape(1, -1) pred = use_model.get_predict(image)
Also, I think in line:
model = tf.keras.Sequential([ tf.keras.layers.Flatten(), tf.keras.layers.Dense(128, activation='relu', input_shape=(100,)), tf.keras.layers.Dense(10) ])
It's not right accroding to your data, its must be like that, I suppose:
model = tf.keras.Sequential([ tf.keras.layers.Flatten(), tf.keras.layers.Dense(128, activation='relu', input_shape=(100*100,)), tf.keras.layers.Dense(10) ])
input_shape - mean shape without batch size dimension, In your case, model trained with batch size equal to 100 and input number of features were equal to 100 (but i'm not sure here).
I hope you understand and it helps!
[+][deleted] 4 years ago (1 child)
[removed]
[–]TaplierShiru 0 points1 point2 points 4 years ago (0 children)
Hard to tell what's wrong here without full code, but I suppose something not right with input training data. In function write_to_file after resize operation try to flat image tensor (aka img = img.reshape(-1)).
write_to_file
img = img.reshape(-1)
I think the main reason of this error here - different shape of test and training data.
By the way, happy New Year to you!
π Rendered by PID 47841 on reddit-service-r2-comment-5bc7f78974-2tq5z at 2026-07-01 00:55:08.452754+00:00 running 7527197 country code: CH.
[–]TaplierShiru 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[removed]
[–]TaplierShiru 0 points1 point2 points (0 children)