当前位置:网站首页>[tf1] save and load parameters
[tf1] save and load parameters
2022-07-05 07:09:00 【hanjialeOK】
tf.keras
Reference resources https://github.com/tensorflow/docs/blob/529ba4346b8fc5e830e762a2f0ee87b3c345c0c9/site/en/r1/guide/keras.ipynb
# Save weights to a TensorFlow Checkpoint file
model.save_weights('./weights/my_model')
# Restore the model's state,
# this requires a model with the same architecture.
model.load_weights('./weights/my_model')
It can also be saved as Keras HDF5 Format
# Save weights to a HDF5 file
model.save_weights('my_model.h5', save_format='h5')
# Restore the model's state
model.load_weights('my_model.h5')
Be careful ,h5 You may encounter this problem https://stackoverflow.com/questions/53740577/does-any-one-got-attributeerror-str-object-has-no-attribute-decode-whi
namely model.load_weights('my_model.h5')
When an error 'str' object has no attribute 'decode'
. terms of settlement :
pip freeze | grep h5py
pip install h5py==2.10.0
tf.train.Saver
You can save the specified parameters . Reference resources https://www.tensorflow.org/api_docs/python/tf/compat/v1/train/Saver
self._saver = tf.train.Saver(var_list=self._get_var_list(), \
max_to_keep=self.max_tf_checkpoints_to_keep)
self._saver.save(
self._sess,
os.path.join(checkpoint_dir, 'tf_ckpt'),
global_step=self.iteration)
self._saver.restore(self._sess,
os.path.join(checkpoint_dir,
'tf_ckpt-{}'.format(iteration_number)))
tf.train.Checkpoint
Don't understand, . Reference resources https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/Checkpoint
边栏推荐
- Orin 安装CUDA环境
- [untitled]
- Pycahrm reports an error: indentation error: unindent does not match any outer indentation
- In C language, int a= 'R'
- IPage can display data normally, but total is always equal to 0
- mysql设置触发器问题
- Instruction execution time
- 一文揭开,测试外包公司的真实情况
- Technology blog learning website
- postmessage通信
猜你喜欢
随机推荐
postmessage通信
ROS2——初识ROS2(一)
Sre core system understanding
Ros2 - Service Service (IX)
Skywalking全部
Technical conference arrangement
SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
UTC, GPS time and Tai
namespace
Ros2 - ros2 vs. ros1 (II)
Concurrent programming - deadlock troubleshooting and handling
Orin two brushing methods
Architecture
The difference between new and malloc
Empire help
2022.06.27_每日一题
Ret2xx---- common CTF template proposition in PWN
Binary search (half search)
[software testing] 02 -- software defect management
. Net core stepping on the pit practice