TensorFlow(3)-与训练相关的操作
與訓(xùn)練相關(guān)的操作
- 0 gpu版本的tensor flow安裝
- 1. tf.control_dependencies(update_ops)
0 gpu版本的tensor flow安裝
cuda10.2
conda create -n py27 python=2.7
conda activate py27
pip install tensorflow==1.14.0
驗證 gpu版本的tensor可用
import tensorflow as tf
print(tf.test.is_gpu_available()) # true 為可用
報錯1: Could not dlopen library ‘libcudart.so.10.0’; dlerror: libcudart.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-11.2/lib64:
解決:安裝cudatoolkit
conda install cudatoolkit=10.0
報錯1: Could not dlopen library ‘libcudnn.so.7’; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-11.2/lib64
解決:安裝cudnn=7.6.5
conda install cudnn=7.6.5
如果你的模型訓(xùn)練出不了效果,可能的原因太多了,沒搞清tf 中各個函數(shù)的具體作用可能就是其中一個原因。本文記錄【如果不理清,會造成無法解釋的訓(xùn)練現(xiàn)象的操作】。
1. tf.control_dependencies(update_ops)
Code Demo
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)with tf.control_dependencies(update_ops):train_op = optimizer.minimize(loss)參考文獻(xiàn):
1.tensorflow中的batch_norm以及tf.control_dependencies和tf.GraphKeys.UPDATE_OPS的探究
2.tf.get_collection(tf.GraphKeys.UPDATE_OPS)
總結(jié)
以上是生活随笔為你收集整理的TensorFlow(3)-与训练相关的操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CRegKey 注册表操作
- 下一篇: AWS的VPC使用经验(一)