
tensorflow
lpflpf5678
这个作者很懒,什么都没留下…
展开
-
LeNet-5卷积网络模型练习(自编)
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("/root/download/inputdata",one_hot=True)batch_size = 50lr = 0.01lrd = 0.99Flage = tf.app.flags.FLAGStf.app.flags.DEFINE_integer("tra原创 2020-06-16 22:04:54 · 304 阅读 · 0 评论 -
tensorflow中有变量的情况下,使用会话注意事项
import tensorflow as tfdef variable(): c=tf.get_variable("b",shape=[2],initializer=tf.constant_initializer(1.0)) w=tf.get_variable("w",shape=[3,2],initializer=tf.constant_initializer([[1,2],[2,3],[3,4]])) #在自定义函数内部调用会话,但是没有给变量初始化,程序报错。尽管在主程序中调原创 2020-06-16 20:09:58 · 182 阅读 · 0 评论 -
tensorflow中的数值运算注意事项
tensorflow中张量,变量,常量进行数值运算都可用符号“+ - * /”,为方便起见,tensorflow中提供了方法。如:加法add = tf.add(a, b)减法sub = tf.subtract(a, b)乘法mul = tf.multiply(a, b)除法div = tf.divide(a, b)包括矩阵、向量的运算以上是严格按照数学的计算形式,进行计算。在tensorflow中定义的一维向量(如tf.get_variable(“b”,shape=[3],in原创 2020-06-16 00:36:15 · 236 阅读 · 0 评论 -
tensorflow中定义变量赋值的注意事项
weight = tf.get_variable("weight",shape=[5,5,1,32],initializer=tf.truncated_normal_initializer(stddev=stddev))bias = tf.get_variable("bias",initializer=tf.constant(b_constant,shape=[b_shape]))get_variable中,设置了shpae,那么initializer必须是数值,如果是张量,那么gei_variabl原创 2020-06-15 22:42:08 · 575 阅读 · 0 评论 -
《tensorflow深度学习算法原理与编程实战》第七章代码(自编)
import tensorflow as tfimport osbatch_size = 50Flages = tf.app.flags.FLAGStf.app.flags.DEFINE_integer("is_train",1,"train or test")class convolutin_picture(object): def __init__(self,filelist): self.filelist = filelist self.lab原创 2020-06-14 18:59:13 · 273 阅读 · 0 评论 -
四维数组的数学理解与tensorflow中对四维数组解释的不同之处
import numpy as npn = np.array([[2,1,2,1], [0,-1,3,0], [2,1,-1,4], [1,2,5,7], [2,1,2,1], [0,1,3,0], [2,1,-1,4], [8,7,9,5], [6,3,2,1],原创 2020-06-10 23:11:28 · 1656 阅读 · 0 评论 -
tensorflow中自定义函数使用placehoer作为实参报错
import tensorflow as tf#定义两个占位符x,y。x和y都是张量x = tf.placeholder(tf.float32)y = tf.placeholder(tf.float32)#自定义一个函数def train(x,y): with tf.Session() as sess: result = print(sess.run(x+y)) return result#调用自定义的函数,把占位符作为实参传递给函数c = train(x,y)原创 2020-06-09 14:52:56 · 238 阅读 · 0 评论 -
softmax_cross_entropy_with_logits()与sparse_softmax_cross_entropy_with_logits()在参数输入上的细微差别
softmax_cross_entropy_with_logits(labels,logits)logitsandlabelsmust have the same shape[batch_size, num_classes]and the same dtype (eitherfloat16,float32, orfloat64`).sparse_softmax_cross_entropy_with_logits(labels,logits)A common use case is to have lo原创 2020-06-08 22:15:05 · 179 阅读 · 0 评论 -
tensorflow中滑动平均值的用法与注意事项
import tensorflow as tfx = tf.Variable(0.0)#定义一个滑动平均值类averages_class = tf.train.ExponentialMovingAverage(0.99)#为变量列表中的每个变量创建一个影子变量。#tf.trainable_variables()返回集合图上中,没有指定trainable_variables= False的变量average_op = averages_class.apply(tf.trainable_var原创 2020-06-07 23:31:32 · 324 阅读 · 0 评论 -
tensorflow中定义的变量与数值相加,类型将发生改变。
import tensorflow as tfx = tf.Variable(0.0)a = tf.global_variables_initializer()with tf.Session() as sess:sess.run(a)y = tf.add(x, 10.0) **#tensorflow中定义的变量必须用tensorflow中提供的函数进行运算** **#得到的结果才能依然是变量**sess.run(tf.assign(x,y)原创 2020-06-07 22:58:55 · 464 阅读 · 0 评论 -
深度学习中为什么加入正则化
为什么这个时候可以尝试收集更多的数据来解决呢?因为,high variance意味着你的训练集和验证集的效果有很大差别,很可能是因为你的训练集里面的数据并不能很好地反映验证集里面的特征,或者说验证集中有一些需要学习到的东西在你的训练集中却没有,所以模型无论如何学习你的训练集,也无法很好地预测验证集的数据,因此我们应该收集更多的数据,学习更多的特征。如果你增加了数据量去训练之后,variance还是很大,那说明我们遇到了典型的 over fitting,我们就需要考虑用 正则化手段了。三、正则化(Regu转载 2020-06-07 20:52:23 · 1311 阅读 · 3 评论 -
运行tensorflow报错
报错:FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.np_resource = np.dtype([(“resource”, np.ubyte, 1)])由于numpy版本过高导致的,安装低版本的numpy例如:pip inst原创 2020-05-17 15:18:14 · 379 阅读 · 0 评论 -
安装tensorflow报错
错误信息Cannot uninstall ‘numpy’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we can原创 2020-05-17 14:33:04 · 247 阅读 · 0 评论