I'm not so sure about the role of the steps parameter in predict_generator, and what I understand is that steps represents the amount of data generated by the generator, but someone denies my answer, and someone confirms my answer I through the practice still couldn't find the right answer, my way is this, I use openslide to read a 5000x5000 size image, each produced a small map 100x100 to forecast the normal I can read 2500 100x100 the size of the picture, but when I set the steps=2500 is wrong
this is code:
# coding=utf-8
from future import division
from keras.models import load_model
import openslide
import numpy as np
import Get_file_name
import generator
import matplotlib.pyplot as plt
def predict_model(img):
model = load_model(Get_file_name.model_path[0])
y= model.predict_generator(generator.pre_gen(img),steps=30)
print(y)
predict_model("cats_and_dogs_5")
this is wrong:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 612, in data_generator_task
generator_output = next(self._generator)
StopIteration
Traceback (most recent call last):
File "/home/zh/视频/MitosisDetection/mitosisDetection/predict.py", line 17, in <module>
predict_model("cats_and_dogs_5")
File "/home/zh/视频/MitosisDetection/mitosisDetection/predict.py", line 12, in predict_model
y= model.predict_generator(generator.pre_gen(img),steps=2500)
File "/usr/local/lib/python3.5/dist-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 1183, in predict_generator
verbose=verbose)
File "/usr/local/lib/python3.5/dist-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 2108, in predict_generator
outs = self.predict_on_batch(x)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 1696, in predict_on_batch
outputs = self.predict_function(ins)
File "/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py", line 2229, in __call__
feed_dict=feed_dict)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 961, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape () for Tensor 'conv2d_1_input:0', which has shape '(?, 64, 64, 3)'
Process finished with exit code 1
If steps represents the amount of data generated by my generator, then why do I set steps=2500 wrong? If steps does not represent the amount of data generated by the generator, then what should I do? What should I do to set the amount of data generated by my generator? Please God more advice, I’m around today, many people do not understand this thing!