
Tensorflow的学习
Peanut_范
计算机视觉、强化学习
展开
-
Win10 RTX30系列 安装tensorflow1.15
Win10 RTX30系列 安装tensorflow1.151.遇到的问题:直接PiP安装,能够安装完成。pip install tensorflow-gpu==1.15并且测试TF的版本和显卡是否正确,也都正常。import tensorflow as tfprint(tf.__version__)print(tf.test.is_gpu_available())但是: 训练会卡住,也不报错,就卡着。遂安装失败。2.最近发现了一个知乎大神的版本废话不多说,上链接: http原创 2021-07-24 15:43:02 · 5187 阅读 · 7 评论 -
TensorFlow报错:This is probably because cuDNN failed to initialize
TensorFlow报错:This is probably because cuDNN failed to initializetensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found. (0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try lo原创 2021-06-10 16:04:12 · 379 阅读 · 0 评论 -
测试Tensorflow、Pytorch的GPU是否可用
测试Tensorflow、Pytorch的GPU是否可用原始环境中为cuda10.0 的Tensorflow1.13.1和Pytorch1.12版本,CUDA通用。虚拟环境中安装了Pytorch1.16,CUDA10.2版本。问题来了:Tensorflow目前最新版本2.4.1竟然不支持CUDA10.2版本,仅支持到CUDA10.1。等着以后支持CUDA10.2在更新版本吧,先用CPU。1.Pytorch测试GPU是否可用2.Tensorflow测试GPU是否可用注: 报了一堆原创 2021-01-23 12:15:40 · 743 阅读 · 0 评论 -
Attempting to use uninitialized value miou/mean_iou/total_confusion_matrix
Tensorflow运行错误记录:FailedPreconditionError (see above for traceback): Attempting to use uninitialized value miou/mean_iou/total_confusion_matrix [[node miou/mean_iou/total_confusion_matrix/read (defined at train.py:178) ]]解决办法:self._sess.run(tf.原创 2020-11-06 15:59:48 · 300 阅读 · 0 评论 -
Tensorflow: tf.add()
Tensorflow: tf.add()1.基本用法: 单个数字和单个数字的简单相加。import tensorflow as tfx = tf.constant(2)y = tf.constant(1)z = tf.add(x,y)with tf.Session() as sess: print(sess.run(z))输出:32.广播机制: 即按维度的相加论文《BiSeNet V2: Bilateral Network with Guided Aggregation f原创 2020-09-07 14:44:00 · 3962 阅读 · 0 评论 -
Tensorflow执行PB模型问题
Tensorflow运行时报错:ValueError: NodeDef mentions attr ‘explicit_paddings’ not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:boo原创 2020-07-08 14:19:57 · 1482 阅读 · 0 评论 -
Tensorflow训练的ckpt模型转pb代码
功能:将tensorflow1.几训练出来的ckpt模型转成pb模型代码:# -*- coding: utf-8 -*-"""@author: fancp"""import tensorflow.compat.v1 as tffrom nets import nets_factoryfrom tensorflow.python.framework import graph_utilFLAGS = tf.app.flags.FLAGStf.app.flags.DEFINE_string(原创 2020-05-26 19:25:34 · 692 阅读 · 0 评论 -
Windows下安装COCOAPI
问题:训练Tensorflow时代码报错ModuleNotFoundError: No module named 'pycocotools’解决:Ananconda命令安装即可pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI结果:...原创 2020-03-25 10:03:08 · 843 阅读 · 0 评论 -
TF训练时报h5py问题
TF运行遇到的问题UserWarning: h5py is running against HDF5 1.10.2 when it was built against 1.10.3, this may cause problems‘{0}.{1}.{2}’.format(*version.hdf5_built_version_tuple)问题原因这个tensorflow基于HDF51....原创 2020-03-17 11:24:23 · 1280 阅读 · 5 评论 -
Tensorflow代码报错:call of
Github下载的Tensorflow代码报错WARNING:tensorflow:Entity <bound method SeparableConv2D.call of <tensorflow.python.layers.convolutional.SeparableConv2D object at 0x0000011F446E9668>> could not be ...原创 2020-03-04 22:58:50 · 2472 阅读 · 0 评论 -
numpy:矩阵或者数组相减
# -*- coding: utf-8 -*-"""numpy:矩阵或者数组相减"""import numpy as npif __name__ == '__main__': feature = np.array([2,3,5]) center = np.array([1,2,3]) print("原始数据维度:") print(featur...原创 2018-11-19 21:45:46 · 26577 阅读 · 0 评论 -
tf.newaxis和np.newaxis
# -*- coding: utf-8 -*-"""tf.newaxis 和 numpy newaxis"""import numpy as npimport tensorflow as tfif __name__ == '__main__': feature = np.array([[1,2,3], [2,4原创 2018-11-19 21:32:25 · 7469 阅读 · 0 评论 -
Tensorflow训练mnist数据(完整版)
重构之后的代码会被拆分成3个程序,第一个是mnist_inference.py,它定义了前向传播的过程以及神经网络中的参数。第二个程序是mnist_train.py,它定义了神经网络的训练过程。第三个程序是mnist_eval.py,它定义了测试过程。原创 2017-07-30 19:51:28 · 2521 阅读 · 0 评论 -
TensorFlow训练mnist数据集(卷积神经网络lenet5)
TensorFlow使用经典卷积神经网络实现对手写数字mnist的训练和测试两个卷积,两个池化,两个全连接层。代码如下:(在上一篇的基础上更改网络lenet5)代码分为3部分,网络-训练和测试# -*- coding: utf-8 -*-"""Created on Tue Jul 25 10:04:39 2017@author: mnist_inference.py"""原创 2017-07-30 23:53:46 · 1809 阅读 · 2 评论 -
TensorFlow:tf.clip_by_value实现值域控制
tf.clip_by_value(A, min, max)函数:输入一个张量A,把A中的每一个元素的值都压缩在min和max之间。小于min的让它等于min,大于max的元素值等于max。代码实现:import tensorflow as tfA = tf.constant([1,2,288,20,100])value = tf.clip_by_value(A, 10, 255)...原创 2018-07-20 07:57:12 · 2629 阅读 · 0 评论 -
TensorFlow:tf.matmul和tf.einsum实现矩阵相乘
TensorFlow:tf.matmul和tf.einsum实现矩阵相乘1.TensorFlow:tf.matmul函数:函数:tf.matmulmatmul( a, b, transpose_a=False, transpose_b=False, adjoint_a=False, adjoint_b=False, a_is...原创 2018-07-21 08:12:51 · 8689 阅读 · 0 评论 -
TensorFlow:tf.get_variable()和tf.Variable()
TensorFlow:tf.get_variable()和tf.Variable()1.tf.get_variable函数函数:tf.get_variable,获取具有这些参数的现有变量或创建一个新变量。 get_variable(name, shape=None, dtype=None, initializer=None, regularizer=None, trainabl...原创 2018-07-21 08:32:50 · 1392 阅读 · 0 评论 -
Tensorflow:GPU训练速度分析
GPU训练速度分析:常见模型会从磁盘中抽取数据,进行预处理,然后通过网络发送数据。例如,处理JPEG图片的模型会有下面的流程:从磁盘加载图片,将JPEG解码成一个tensor,进行裁减(crop)和补齐(pad),可能还会进行翻转(flip)和扭曲(distort),然后再batch。该流程被称为input pipeline。随着GPUs和其它硬件加速器越来越快,数据预处理可能是个瓶颈。...原创 2018-09-06 21:32:32 · 8283 阅读 · 1 评论 -
Tensorflow:CPU性能分析
iostatiostat用于输出CPU和磁盘I/O相关的统计信息. 命令格式: 1)显示所有设备负载情况 指令: iostat -m 2 5 cpu属性值说明: %user:CPU处在用户模式下的时间百分比。 %nice:CPU处在带NICE值的用户模式下的时间百分比。 %system:CPU处在系统模式下的时间百分比。 %iowait:CPU等待输入输出完...原创 2018-09-06 21:43:31 · 3135 阅读 · 0 评论 -
Tensorflow:GPU使用几点建议
GPU运行Tensorflow的几点建议:1.在运行之前先查看GPU的使用情况: 指令:nvidia-smi 备注:查看GPU此时的使用情况 或者 指令:watch nvidia-smi 备注:实时返回GPU使用情况2.指定GPU训练: 方法一、在python程序中设置: 代码:os.environ[‘CUDA_VISIBLE_DEVICES’] = ‘0’ 备注:使...原创 2018-09-06 21:48:26 · 10688 阅读 · 3 评论 -
Variable和Tensor的区别?
Tensor和Variable的区别代码: c=a+bimport tensorflow as tfa = tf.Variable(1.0,name='a')b = tf.Variable(2.0,name='b')c = tf.add(a,b)sess = tf.Session()sess.run(tf.global_variables_initializer())pri...原创 2018-10-07 20:06:06 · 7177 阅读 · 1 评论 -
Tensorflow的入门级程序(神经网络mnist)
Tensorflow训练mnist数据原创 2017-07-30 13:29:57 · 665 阅读 · 0 评论