Я пытаюсь передать изображения размером (350x350x3)
в качестве формы ввода и хочу обучить сеть выводить (1400x1400x3)
изображение (4-кратное увеличение).
Мой обучающий набор данных состоит из 8images 1400x1400x3
, которые я переворачиваю, чтобы получить 32 изображения для проверки.
Затем я уменьшаю эти 32 изображения до 350x350x3
, чтобы получить входные изображения, которые будут перекрестно проверены сих 32 других аналога.
print(type(validateData))
print(validateData.shape)
print(type(validateData[0].shape))
print(validateData[0].shape)
возвращает
<class 'numpy.ndarray'>
(32,)
<class 'tuple'>
(1400, 1400, 3)
И, аналогично:
print(type(trainingData)) # <class 'numpy.ndarray'>
print(trainingData.shape) # (32,)
print(type(trainingData[0].shape)) # <class 'tuple'>
print(trainingData[0].shape) # (350, 350, 3)
Так что, когда я делаю
model.fit(trainingData,
validateData,
epochs=5,
verbose=2,
batch_size=4) # 32 images-> 8 batches of 4
Что именно я должен ввести в качестве двух первых параметров функции .fit
?
Как есть, я получаю эту ошибку:
ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (32, 1)
Вот мой полный код , если вы хотите посмотреть его.
Keras API не очень ясно о форматировании данных, которые должны быть предоставлены:
fit
fit(x=None, y=None, batch_size=None, epochs=1, verbose=1, callbacks=None, validation_split=0.0, validation_data=None, shuffle=True, class_weight=None, sample_weight=None, initial_epoch=0, steps_per_epoch=None, validation_steps=None)
Trains the model for a given number of epochs (iterations on a dataset).
Arguments
x: Numpy array of training data (if the model has a single input), or list of Numpy arrays (if the model has multiple inputs). If input layers in the model are named, you can also pass a dictionary mapping input names to Numpy arrays. x can be None (default) if feeding from framework-native tensors (e.g. TensorFlow data tensors).
y: Numpy array of target (label) data (if the model has a single output), or list of Numpy arrays (if the model has multiple outputs). If output layers in the model are named, you can also pass a dictionary mapping output names to Numpy arrays. y can be None (default) if feeding from framework-native tensors (e.g. TensorFlow data tensors).
Вот полный код другой реализации , которую я пытался использовать.На этот раз я изменил параметры, чтобы они были списками Python для np_arrays (каждое изображение является трехмерным np_array).Теперь я получаю эту ошибку:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 32 arrays: [array([[[0.6774938 , 0.64219969, 0.60690557],
[0.67257049, 0.63743775, 0.60206295],
[0.67203473, 0.6418085 , 0.60398018],
...,
[0.55292714, 0.5253832 , 0.46217287],
...
Трудно понять, ближе я или дальше.