当前位置:网站首页>[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
边栏推荐
- [untitled]
- ROS2——配置开发环境(五)
- Volcano resource reservation feature
- Log4qt usage of logbase in QT project
- ROS2——安装ROS2(三)
- [software testing] 06 -- basic process of software testing
- 1290_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
- 能量守恒和打造能量缺口
- 扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
- Preemption of CFS scheduling
猜你喜欢
随机推荐
Positive height system
An article was opened to test the real situation of outsourcing companies
Mipi interface, DVP interface and CSI interface of camera
你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
6-4 search by serial number of linked list
在本地搭建一个微服务集群环境,学习自动化部署
SD_CMD_SEND_SHIFT_REGISTER
ethtool 原理介绍和解决网卡丢包排查思路(附ethtool源码下载)
6-2 sequence table operation set
一文揭开,测试外包公司的真实情况
并发编程 — 死锁排查及处理
[nvidia] CUDA_ VISIBLE_ DEVICES
Ros2 - ros2 vs. ros1 (II)
C语言数组专题训练
基于FPGA的一维卷积神经网络CNN的实现(八)激活层实现
Interpretation of the earliest sketches - image translation work sketchygan
Error: "mountvolume.setup failed for volume PVC fault handling
Orin installs CUDA environment
In C language, int a= 'R'
Xavier CPU & GPU 高负载功耗测试