작성
·
827
·
수정됨
2
당장 문의드리는 것은 CIFAR10_Pretained이지만 다른 예제를 실행해도 같은 에러가 납니다.
tr_data_len = tr_images.shape[0]
val_data_len = val_images.shape[0]
history = vgg_model.fit(flow_tr_gen, epochs=40,
steps_per_epoch=int(np.ceil(tr_data_len/BATCH_SIZE)),
validation_data=flow_val_gen,
validation_steps=int(np.ceil(val_data_len/BATCH_SIZE)),
callbacks=[rlr_cb, ely_cb])
)
이 셀을 실행시키면, 이런 식으로 홀수만 학습이 되고 짝수는 학습이 안 됩니다.
이 학습시킨 것을 그래프로 나타내면 0이 되었다가 정상적으로 되었다가 반복을 하네요.
예전에 예제를 실행시켰을때는 이런 오류가 없었는데 버전이 업데이트되면서 안되는것 같습니다.
Adam 함수에 매개변수 lr=을 입력할 때도 에러가 나서 learning_rate=로 변경해야하는 식으로 자잘한 문제도 있습니다.
많은 예제에서 같은 오류가 나는 것을 보아 업데이트된 캐글 커널 버전에 맞춰서 코드를 전체적으로 수정하셔야할 필요가 있을것 같습니다.
감사합니다.
Epoch 1/40
/opt/conda/lib/python3.10/site-packages/keras/src/trainers/data_adapters/py_dataset_adapter.py:122: UserWarning: Your `PyDataset` class should call `super().__init__(**kwargs)` in its constructor. `**kwargs` can include `workers`, `use_multiprocessing`, `max_queue_size`. Do not pass these arguments to `fit()`, as they will be ignored.
self._warn_if_super_not_called()
10/665 ━━━━━━━━━━━━━━━━━━━━ 12s 19ms/step - accuracy: 0.0987 - loss: 3.5617
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1709598886.339819 103 device_compiler.h:186] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.
665/665 ━━━━━━━━━━━━━━━━━━━━ 31s 30ms/step - accuracy: 0.1981 - loss: 2.1133 - val_accuracy: 0.4116 - val_loss: 1.5764
Epoch 2/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 28us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 3/40
7/665 ━━━━━━━━━━━━━━━━━━━━ 12s 18ms/step - accuracy: 0.4141 - loss: 1.5560
/opt/conda/lib/python3.10/contextlib.py:153: UserWarning: Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches. You may need to use the `.repeat()` function when building your dataset.
self.gen.throw(typ, value, traceback)
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.4451 - loss: 1.4449 - val_accuracy: 0.5769 - val_loss: 1.2619
Epoch 4/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 5/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.5782 - loss: 1.1673 - val_accuracy: 0.5975 - val_loss: 1.1887
Epoch 6/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 17us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 7/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.6474 - loss: 1.0090 - val_accuracy: 0.6819 - val_loss: 1.1508
Epoch 8/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 17us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 9/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.6889 - loss: 0.8978 - val_accuracy: 0.6689 - val_loss: 1.2804
Epoch 10/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 11/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.7189 - loss: 0.8345 - val_accuracy: 0.7216 - val_loss: 1.0568
Epoch 12/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 17us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 13/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.7289 - loss: 0.8169 - val_accuracy: 0.7328 - val_loss: 1.3400
Epoch 14/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 17us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 15/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.7646 - loss: 0.7047 - val_accuracy: 0.6892 - val_loss: 1.1569
Epoch 16/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 17/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.7645 - loss: 0.7083 - val_accuracy: 0.7511 - val_loss: 0.9342
Epoch 18/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 19/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.7857 - loss: 0.6478 - val_accuracy: 0.7740 - val_loss: 0.9626
Epoch 20/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 21/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.8012 - loss: 0.6048 - val_accuracy: 0.7763 - val_loss: 0.7990
Epoch 22/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 23/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.8056 - loss: 0.5998 - val_accuracy: 0.7719 - val_loss: 0.8663
Epoch 24/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 25/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.8196 - loss: 0.5483 - val_accuracy: 0.7731 - val_loss: 0.8920
Epoch 26/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 27/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 13s 19ms/step - accuracy: 0.8313 - loss: 0.5199 - val_accuracy: 0.7960 - val_loss: 0.8204
Epoch 28/40
665/665 ━━━━━━━━━━━━━━━━━━━━ 0s 16us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00 - val_accuracy: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 29/40
답변 2
2
확인 결과 tensorflow 버전이 업그레이드 되면서 더 이상 fit() 호출 시 steps_per_epoch와 validation_steps 인자를 적용하면 안될 것 같습니다. 이걸 적용하지 않아도 내부에서 잘 계산이 됩니다.
아래와 같이 적용되어야 합니다.
history = vgg_model.fit(flow_tr_gen, epochs=40,
validation_data=flow_val_gen,
callbacks=[rlr_cb, ely_cb])
)
해당 내용에 대해서는 별도로 영상을 만들어서 전체 공지 하도록 하겠습니다.
감사합니다.
1
안녕하십니까,
말씀 하신대로 캐글 환경이 바뀌어서 이슈가 있군요.
제가 좀 더 시간을 가지고 방법을 찾아봐야 할 것 같습니다. 조만간 다시 말씀드리겠습니다.
좋은 정보 감사합니다.