tensorflow学习
计算机视觉小白,主要记录tensorflow学习笔记,欢迎各路大神批评指正
GAN_player
渣硕一枚
展开
-
tensorflow如何队列式同步批量读取照片(1)
下载即用。一定要注意,首先要下载cifar数据集,解压放在datasets文件夹下。import tensorflow as tffrom tensorflow import flagsimport osfrom scipy import miscflags.DEFINE_string('data_dir','datasets/',"""Path to the CIFAR-10 data d原创 2017-07-31 14:40:55 · 1045 阅读 · 0 评论 -
tensorflow如何队列式同步批量读取照片(2)
import tensorflow as tffrom scipy import miscimport numpy as npdef read_cifar10(filename_queue): reader = tf.WholeFileReader() key, value = reader.read(filename_queue) record_bytes = tf.image.d原创 2017-08-01 20:58:01 · 4432 阅读 · 1 评论 -
tfrecorder的制作/读取(附实战代码)
import tensorflow as tf import numpy def write_binary(): writer = tf.python_io.TFRecordWriter('data.tfrecord') #创建example for i in range(0, 100): a = 0.618 + i原创 2017-08-02 00:02:50 · 2282 阅读 · 0 评论 -
tensorflow实现线性svm
简单方法:import tensorflow as tfimport numpy as npfrom matplotlib import pyplot as pltdef placeholder_input(): x=tf.placeholder('float',shape=[None,2],name='x_batch') y=tf.placeholder('float',sha原创 2017-08-07 11:37:07 · 1137 阅读 · 0 评论 -
对比 tf.layers.conv2d_transpose和tf.nn.conv2d_transpose区别
都表示反卷积,但是参数不同。使用方法对比如下:import tensorflow as tf x1 = tf.ones(shape=[64,7,7,256]) y1 = tf.layers.conv2d_transpose(x1, 128, 3, strides=2, padding='SAME') w=tf.ones([3,3,128,256])y2 = tf.nn.conv2d_tra原创 2017-08-11 23:44:01 · 7466 阅读 · 4 评论 -
tensorflow中batch_normalization的坑
import tensorflow as tfimport numpy as npa=np.array([[5.,8.,2.],[7.,9.,1.]])a=np.expand_dims(a,axis=0)a=tf.constant(a,dtype=tf.float32) a_mean, a_var = tf.nn.moments(a, axes=[0,1],keep_dims=True)b原创 2017-08-22 19:11:48 · 7187 阅读 · 1 评论 -
tf.get_collection获取训练变量等效用法
# train_vars=tf.trainable_variables()# g_vars=[var for var in train_vars if var.name.startswith('generator')]# d_vars=[var for var in train_vars if var.name.startswith('discriminator')]原创 2017-08-23 11:22:54 · 8558 阅读 · 1 评论 -
tf.identity()的理解
import tensorflow as tfx = tf.Variable(1.0)x_plus_1 = tf.assign_add(x, 1)with tf.control_dependencies([x_plus_1]): y = x z=tf.identity(x,name='x')init = tf.global_variables_initializer()wit原创 2017-08-23 20:43:47 · 11885 阅读 · 2 评论 -
如何将tensorflow程序移植到手机APP
首先,我们先介绍tensorflow上提供的demo。 我们这里用Bazel。一.下载tensorflow。git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git二.安装Bazel。安装教程:https://docs.bazel.build/versions/master/install.html三.安原创 2017-08-25 11:28:33 · 1883 阅读 · 0 评论 -
DCGAN生成彩色图片
我们以cifar数据集作为训练数据import tensorflow as tfimport matplotlib.pyplot as pltimport numpy as npmnist = np.load('images.npy')print('---------load data successful-----------')def input_placeholder(img_size,原创 2017-08-15 20:02:51 · 4768 阅读 · 1 评论 -
tf.where 和 tf.cond对比
import tensorflow as tfpred=tf.placeholder(dtype=tf.bool,name='bool')x=tf.constant(1)y = tf.cond(pred,lambda:x+1,lambda:x-1)z=tf.where(pred,x+1,x-1)with tf.Session() as sess: sess.run(tf.global_原创 2017-09-01 21:00:06 · 9250 阅读 · 0 评论