У меня есть пять папок, и у каждой папки есть 25 точек данных. Мы разбиваем данные на разделы обучения и тестирования таким образом, что 75% данных предназначены для обучения, а оставшиеся 25% - для тестирования. Вот мой код
batch_size = 128
epochs = 50
model= create_model()
sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='mean_squared_error', optimizer=sgd, metrics=['accuracy'])
early_stopping=callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=10, verbose=0, mode='min')
filepath="top_model.h5"
checkpoint = callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='min')
callbacks_list = [early_stopping,checkpoint]
model.fit(trainX, trainY,shuffle=True,
batch_size=batch_size,
epochs=epochs,
verbose=1,
validation_data=(testX, testY),callbacks=callbacks_list)
И выполнение приведенного выше кода показывает эту ошибку
Train on 1560 samples, validate on 520 samples
IndexError Traceback (most recent call last)
<ipython-input-71-8fd14ef9b0fb> in <module>
3 epochs=epochs,
4 verbose=1,
----> 5 validation_data=(testX, testY),callbacks=callbacks_list)
~\Anaconda3\lib\site-packages\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
1237 steps_per_epoch=steps_per_epoch,
1238 validation_steps=validation_steps,
-> 1239 validation_freq=validation_freq)
1240
1241 def evaluate(self,
~\Anaconda3\lib\site-packages\keras\engine\training_arrays.py in fit_loop(model, fit_function, fit_inputs, out_labels, batch_size, epochs, verbose, callbacks, val_function, val_inputs, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq)
139 indices_for_conversion_to_dense = []
140 for i in range(len(feed)):
--> 141 if issparse(fit_inputs[i]) and not K.is_sparse(feed[i]):
142 indices_for_conversion_to_dense.append(i)
143
IndexError: list index out of range