게시글
질문&답변
train_isbi_2012.py 실행중 epoch첫번째 끝나고 모델을 저장할때 뜨는 에러입니다.
자꾸 질문드려 죄송합니다. 말씀해주신대로 h5 저장방식에서 바뀌었다 보니까, evaluate에서 저장된 모델을 다시 불러오는 부분도 바꿔서 진행해야할것같아 공식홈페이지 참고하여 flags.DEFINE_string('checkpoint_path', default='/unet_model', help='path to a directory to restore checkpoint file') 위와같이 저장할때의 마찬가지의 경로로 바꾸어 주었구 로드하는 부분도 공식홈피에 설명에따라 원래 코드 주석처리하고 # unet_model.load_weights(FLAGS.checkpoint_path) unet_model.load_model(FLAGS.checkpoint_path) 위와같이 바꾸었는데, Traceback (most recent call last): File "evaluate_isbi_2012.py", line 90, in app.run(main) File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/absl/app.py", line 312, in run _run_main(main, args) File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main sys.exit(main(argv)) File "evaluate_isbi_2012.py", line 67, in main unet_model.load_model(FLAGS.checkpoint_path) AttributeError: 'UNET_ISBI_2012' object has no attribute 'load_model' load_model이라는 속성이 없다고 나오더라구요(공식홈피는 아래 링크를 참조했습니다.) https://www.tensorflow.org/tutorials/keras/save_and_load?hl=ko UNET_ISBI_2012가 모델 속성을 받은 함수여서 그대로 사용하면 될줄알았는데, 위와같은 오류가뜨면 어떻게 해결해야하는지 여쭙습니다.
- 0
- 3
- 1.5K
질문&답변
train_isbi_2012.py 실행중 epoch첫번째 끝나고 모델을 저장할때 뜨는 에러입니다.
train_isbi_2012.py:180: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators. unet_model.fit_generator(train_generator, Epoch 1/5 2022-03-28 15:40:59.839414: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 1207959552 exceeds 10% of free system memory. 2022-03-28 15:40:59.851804: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 1207959552 exceeds 10% of free system memory. 1/2000 [..............................] - ETA: 8:28:49 - loss: 0.5343 - accuracy: 0.75872022-03-28 15:41:14.463919: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 1207959552 exceeds 10% of free system memory. 2022-03-28 15:41:14.464060: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 1207959552 exceeds 10% of free system memory. 2/2000 [..............................] - ETA: 8:31:23 - loss: 0.6406 - accuracy: 0.77262022-03-28 15:41:29.882777: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 1207959552 exceeds 10% of free system memory. 2000/2000 [==============================] - ETA: 0s - loss: 0.1751 - accuracy: 0.9234 Epoch 1: loss improved from inf to 0.17507, saving model to unet_model.h5 Traceback (most recent call last): File "train_isbi_2012.py", line 186, in app.run(main) File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/absl/app.py", line 312, in run _run_main(main, args) File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main sys.exit(main(argv)) File "train_isbi_2012.py", line 180, in main unet_model.fit_generator(train_generator, File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/keras/engine/training.py", line 2209, in fit_generator return self.fit( File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "/media/jjaysohn/Jangjay/Pydicom_read/U-Netpractice/U-net/lib/python3.8/site-packages/keras/saving/save.py", line 140, in save_model raise NotImplementedError( NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using `save_weights`. 2022-03-28 23:02:14.273774: W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: FAILED_PRECONDITION: Python interpreter state is not initialized. The process may be terminated. [[{{node PyFunc}}]] 말씀주신대로 실행해보았는데, 마찬가지 오류가 떴어요 ㅠ. 좀더 찾아볼텐데, 혹시 추가 해결법 아시는법 있으면 알려주시면 감사하겠습니다. 감사합니다.
- 0
- 3
- 1.5K