
TensorFlow
xbs118
梦里不知身是客,醒来方知一场空。
展开
-
解决tensorflow报错ValueError: Variable conv1/weights already exists, disallowed.
原因重新加载已有模型。解决重开控制台(重跑)在要重复运行的开始处加上:tf.reset_default_graph()转载 2019-03-26 16:06:18 · 2195 阅读 · 0 评论 -
TensorFlow 分布式 集群 部署
TensorFlow从0.8版本后即可进行分布式的集群部署,本文参考至 https://blog.youkuaiyun.com/sydpz1987/article/details/51340277 ,由TensorFlow分布式部署手册翻译而来。本文已默认您对TensorFlow和Python编程已经具有一定的基础。1 入门例子先来看一个例子。# Start a TensorFlow server a...转载 2019-08-10 21:09:06 · 2809 阅读 · 0 评论 -
tf.conv1d 和 tf.conv2d 的区别
tf.conv1d是实现一维卷积,tf.conv2d是实现二维卷积。当tf.conv2d的输入第二个或第三个维度为1时就等同于一维卷积了,详细见以下代码。import tensorflow as tfimport numpy as npinput = tf.constant([[[1], [7], [3], [2], [5], [6], [1]], [[11], [17], [13], ...原创 2019-08-02 08:44:01 · 3690 阅读 · 0 评论 -
tensorflow 选择参数进行训练的方法
1 一般的训练过程train的过程其实就是修改计算图中的tf.Variable的过程。import tensorflow as tf label = tf.constant(1,dtype = tf.float32)prediction_to_train = tf.Variable(3,dtype=tf.float32) # 指定了待训练的变量(参数)manual_compute_l...转载 2019-07-28 10:45:34 · 3225 阅读 · 2 评论 -
tf.slice的理解
1 源代码注释的解释This operation extracts a slice of size size from a tensor input starting at the location specified by begin. The slice size is represented as tensor shape, where size[i] is the number of ...原创 2019-07-29 12:11:38 · 1503 阅读 · 0 评论 -
...weights already exists, disallowed. Did you mean to set reuse=True...(解决办法)
出错原因是TensorFlow的变量名被重新定义了。解决:1 若想要继续使用并共享当前的TensorFlow模型结构或变量:按照报错的提示信息加上reuse=True,例如:with tf.variable_scope("a",reuse=True): b = tf.get_variable("b",[0])2 若想要继续使用但不共享当前的TensorFlow模型结构或变量:...原创 2019-05-26 21:59:12 · 3277 阅读 · 2 评论 -
一行命令解决 深度学习环境 TensorFlow PyTorch Keras安装 cuda cudnn 配置
估计你已经被深度学习环境的安装和配置整得焦头烂额了,cuda和cudnn的安装配置真的好麻烦,下面我将告诉你只要用一行代码就可以解决这个问题。不过首先,你得下载安装anaconda环境,而不是使用纯Python软件。然后创建一个你想要运行深度学习的环境。一般使用过Python的人,以上两步都已经完成,新手的话可以自行查阅如何解决,很简单。最后。。。。。。进入终端,进入自己的环境。。。。。...原创 2019-05-17 10:13:51 · 521 阅读 · 0 评论 -
深度学习 tensorflow中的padding:valid和same
1 TensorFlow给出的定义The TensorFlow Convolution example gives an overview about the difference between SAME and VALID :For the SAME padding, the output height and width are computed as:out_height = ce...原创 2019-05-03 14:12:13 · 583 阅读 · 0 评论 -
tf.placeholder 解释
Tensorflow的设计理念称之为计算流图,在编写程序时,首先构筑整个系统的graph,代码并不会直接生效,这一点和python的其他数值计算库(如Numpy等)不同,graph为静态的,类似于docker中的镜像。然后,在实际的运行时,启动一个session,程序才会真正的运行。这样做的好处就是:避免反复地切换底层程序实际运行的上下文,tensorflow帮你优化整个系统的代码。我们知道...转载 2019-04-06 20:39:20 · 788 阅读 · 0 评论 -
tf.ConfigProto() 和tensorflow的GPU配置
# 使用0, 2, 3三块GPUos.environ['CUDA_VISIBLE_DEVICES'] = '0, 2, 3'#设置每个GPU应该拿出多少容量给进程使用,0.6表示60%gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.6)config=tf.ConfigProto( gpu_options=gpu_...原创 2019-04-05 17:04:28 · 904 阅读 · 0 评论 -
机器学习模型攻防cleverhans库中的mnist_blackbox.py例子 介绍
cleverhans是一个机器学习模型攻防库,里面有很多的攻防技术实现。下面来具体介绍一下其下mnist_blackbox.py文件的例子。它实现了 https://arxiv.org/abs/1602.02697 中的黑盒攻击方法:实现了TensorFlow创建一个使用minst训练的黑盒分类模型。生成数据使用黑盒分类模型将其标注。使用标注数据拟合替代检测器。使用替代检测器生成对...原创 2019-03-24 15:51:38 · 2560 阅读 · 0 评论 -
tf.app.flags 和 tf.app.run
https://www.jianshu.com/p/55cbd3753ee8转载 2019-04-04 20:00:40 · 333 阅读 · 0 评论 -
机器学习模型攻防cleverhans库中的mnist_tutorial_tf.py例子 介绍
cleverhans是一个机器学习模型攻防库,里面有很多的攻防技术实现。下面来具体介绍一下其下mnist_tutorial_tf.py文件的例子。它实现了以下方法:实现了TensorFlow创建一个使用minst训练的模型。然后使用FGSM方法生成对抗样本。然后通过对抗训练使得模型对对抗样本更具有鲁棒性。先贴出代码:(注意要在该库函数下才能运行该代码)"""This tutor...原创 2019-03-24 14:21:55 · 3989 阅读 · 43 评论 -
intra_op_parallelism_threads参数设置
1 问题如代码: # Create TF session if num_threads: config_args = dict(intra_op_parallelism_threads=5) # 1 => 5 else: config_args = {} sess = tf.Session(config=tf.ConfigProto(**config_ar...原创 2019-03-23 16:04:41 · 7541 阅读 · 0 评论 -
tf.reduce_sum的使用
import tensorflow as tfa = tf.constant([[[1,2],[11,12]], [[21,22],[31,32]]])sum1 = tf.reduce_sum(a)sum2 = tf.reduce_sum(a, 0)sum3 = tf.reduce_sum(a, 1)sum4 = tf.reduce_sum(a, 2)sum5 = tf.reduce...原创 2019-08-15 17:05:44 · 325 阅读 · 0 评论