• 카테고리

    질문 & 답변
  • 세부 분야

    컴퓨터 비전

  • 해결 여부

    해결됨

ImportError: `save_model` requires h5py.

20.10.19 01:20 작성 조회수 1.04k

0

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-33-c7a37fcec862> in <module>

      4                    epochs = epochs,

      5                    batch_size = batch_size,

----> 6                    callbacks = [modelCheckpoint, monitor_val_lose] )

~/.local/lib/python3.7/site-packages/tensorflow_core/python/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)

    764         max_queue_size=max_queue_size,

    765         workers=workers,

--> 766         use_multiprocessing=use_multiprocessing)

    767 

    768   def evaluate(self,

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_arrays.py in fit(self, model, 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, **kwargs)

    678         validation_steps=validation_steps,

    679         validation_freq=validation_freq,

--> 680         steps_name='steps_per_epoch')

    681 

    682   def evaluate(self,

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_arrays.py in model_iteration(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq, mode, validation_in_fit, prepared_feed_values_from_dataset, steps_name, **kwargs)

    452     if mode == ModeKeys.TRAIN:

    453       # Epochs only apply to `fit`.

--> 454       callbacks.on_epoch_end(epoch, epoch_logs)

    455     progbar.on_epoch_end(epoch, epoch_logs)

    456 

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/callbacks.py in on_epoch_end(self, epoch, logs)

    298     logs = logs or {}

    299     for callback in self.callbacks:

--> 300       callback.on_epoch_end(epoch, logs)

    301 

    302   def on_train_batch_begin(self, batch, logs=None):

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/callbacks.py in on_epoch_end(self, epoch, logs)

    972           self._save_model(epoch=epoch, logs=logs)

    973       else:

--> 974         self._save_model(epoch=epoch, logs=logs)

    975     if self.model._in_multi_worker_mode():

    976       # For multi-worker training, back up the weights and current training

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/callbacks.py in _save_model(self, epoch, logs)

   1008               self.model.save_weights(filepath, overwrite=True)

   1009             else:

-> 1010               self.model.save(filepath, overwrite=True)

   1011           else:

   1012             if self.verbose > 0:

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py in save(self, filepath, overwrite, include_optimizer, save_format, signatures, options)

    984     """

    985     saving.save_model(self, filepath, overwrite, include_optimizer, save_format,

--> 986                       signatures, options)

    987 

    988   def save_weights(self, filepath, overwrite=True, save_format=None):

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py in save_model(model, filepath, overwrite, include_optimizer, save_format, signatures, options)

    110           'or using `save_weights`.')

    111     hdf5_format.save_model_to_hdf5(

--> 112         model, filepath, overwrite, include_optimizer)

    113   else:

    114     saved_model_save.save(model, filepath, overwrite, include_optimizer,

~/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py in save_model_to_hdf5(model, filepath, overwrite, include_optimizer)

     71 

     72   if h5py is None:

---> 73     raise ImportError('`save_model` requires h5py.')

     74 

     75   # TODO(psv) Add warning when we save models that contain non-serializable

ImportError: `save_model` requires h5py.

파이썬 : 3.7.3

텐서플로우 : 1.14.0

h5py : 2.10.0

설치되어 있습니다.. 해결방법을 모르겠네요

답변 3

·

답변을 작성해보세요.

0

J S님의 프로필

J S

질문자

2020.10.20

https://stackoverflow.com/questions/43385565/importerrorsave-weights-requires-h5py/47856532

위 내용 참고하여 해결했습니다.

0

J S님의 프로필

J S

질문자

2020.10.19

해당 영상에서 나오는 코드 중

history = model.fit(x_train, 

                   y_train,

                   validation_data = (x_test, y_test),

                   epochs = epochs,

                   batch_size = batch_size,

                   callbacks = [monitor_val_lose, modelCheckpoint] )

callbacks modelCheckpoint부분에서 발생하는 오류입니다.

0

안녕하세요?

문제가 되는 예제 프로그램이름과 에러가 발생하는 곳을 알려주시겠어요?

감사합니다.