Я тренирую модель DL с использованием Keras в Google Colab.При обучении модели, если я изменяю параметры увеличения изображения (или), если я изменяю увеличение изображения, точность начинается с 0 еще раз, несмотря на предыдущую точность любого значения (20% или 40%).Итак, я вынужден использовать те же методы увеличения и получить плато ...
model.fit(X_train_new, Y_train,
batch_size=128,
nb_epoch=20,
validation_data=(X_test_new, Y_test),
shuffle=True,
callbacks=callbacks)
Вывод:
Epoch 20/20
100000/100000 [==============================] - 231s 2ms/step - loss: 3.5002 - acc: 0.2198 - val_loss: 3.9516 - val_acc: 0.1587
Epoch 00020: val_acc improved from 0.15840 to 0.15870, saving model to /content/gdrive/My Drive/Colab Notebooks/Ultimate/weights-improvement-20-0.16.h5
<keras.callbacks.History at 0x7f2ec2f1a1d0>
Теперь, когда я сохраняю и загружаю модель (или) дажебез загрузки модели, если я возобновлю:
from keras.models import load_model
model.save('/content/gdrive/My Drive/Colab Notebooks/Ultimate/model-cell-1-final.h5')
#del model
!ls '/content/gdrive/My Drive/Colab Notebooks/Ultimate/'
from keras.models import load_model
model = load_model('/content/gdrive/My Drive/Colab Notebooks/Ultimate/model-cell-1-final1.h5')
from imgaug import augmenters as iaa
#seq = iaa.Sequential([...]) # list of desired augmentors
seq = iaa.Sequential([
iaa.Fliplr(0.5), # horizontal flips
iaa.Crop(percent=(0, 0.1)), # random crops
# Small gaussian blur with random sigma between 0 and 0.5.
# But we only blur about 50% of all images.
iaa.Sometimes(0.5,
iaa.GaussianBlur(sigma=(0, 0.5))
),
# Strengthen or weaken the contrast in each image.
iaa.ContrastNormalization((0.75, 1.5)),
# Add gaussian noise.
# For 50% of all images, we sample the noise once per pixel.
# For the other 50% of all images, we sample the noise per pixel AND
# channel. This can change the color (not only brightness) of the
# pixels.
iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5),
# Make some images brighter and some darker.
# In 20% of all cases, we sample the multiplier once per channel,
# which can end up changing the color of the images.
iaa.Multiply((0.8, 1.2), per_channel=0.2),
# Apply affine transformations to each image.
# Scale/zoom them, translate/move them, rotate them and shear them.
iaa.Affine(
scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
rotate=(-25, 25),
shear=(-8, 8)
)
], random_order=True) # apply augmenters in random order
ig = ImageDataGenerator(preprocessing_function=seq.augment_image) # pass this as the preprocessing function
#gen = ig.flow_from_directory(data_dir) # nothing else changes with the generator
ig.fit(X_train_new)
#Train our model using ImgAug Augmentation
model.fit_generator(ig.flow(X_train_new, Y_train, batch_size=128),
steps_per_epoch=200,
epochs=20,
verbose=1,
validation_data=(X_test_new, Y_test),
callbacks=callbacks)
Это снова начинается с точности 0%
Epoch 1/20
200/200 [==============================] - 97s 487ms/step - loss: 5.6513 - acc: 0.0152 - val_loss: 5.2551 - val_acc: 0.0213
Epoch 00001: val_acc improved from -inf to 0.02130, saving model to /content/gdrive/My Drive/Colab Notebooks/Ultimate/weights-improvement-01-0.02.h5
WARNING:tensorflow:From <ipython-input-13-69a262e916e5>:21: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
- LR: 0.033921
Это происходит, даже если я использую методы расширения ImageDatagenerator и не знаючто я могу сделать, чтобы исправить это