当前位置:网站首页>[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
边栏推荐
- Initialization of global and static variables
- SOC_SD_CMD_FSM
- Ros2 - Service Service (IX)
- Cookie、Session、JWT、token四者间的区别与联系
- Ros2 - workspace (V)
- Executealways of unity is replacing executeineditmode
- [software testing] 03 -- overview of software testing
- .net core踩坑实践
- Powermanagerservice (I) - initialization
- mingling
猜你喜欢
随机推荐
Ros2 - install ros2 (III)
Ros2 - first acquaintance with ros2 (I)
Mipi interface, DVP interface and CSI interface of camera
Ros2 - configuration development environment (V)
ROS2——ROS2对比ROS1(二)
三体目标管理笔记
Instruction execution time
window navicat连接阿里云服务器mysql步骤及常见问题
SD_ CMD_ SEND_ SHIFT_ REGISTER
Marvell 88E1515 PHY loopback模式测试
逻辑结构与物理结构
6-4 search by serial number of linked list
Unity ugui how to match and transform coordinates between different UI panels or uis
Orin two brushing methods
Unity 之 ExecuteAlways正在取代ExecuteInEditMode
网易To B,柔外刚中
A brief introduction to heading/pitch/roll and omega/phi/kappa
SOC_ SD_ CMD_ FSM
[tf] Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initial
[OBS] x264 Code: "buffer_size“

![[untitled]](/img/d5/2ac2b15818cf66c241e307c6723d50.jpg)







