tensorflow
神坑教无心
这个作者很懒,什么都没留下…
展开
-
图像编码处理
import tensorflow as tfimport matplotlib.pyplot as pltimage_raw_data = tf.gfile.FastGFile('cat.jpg', 'rb').read()with tf.Session() as sess: img_data = tf.image.decode_jpeg(image_raw_data) ...原创 2018-05-02 15:43:56 · 555 阅读 · 0 评论 -
卷积神经网络训练MNIST
#-*-coding:utf-8-*-from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfimport numpy as npmnist = input_data.read_data_sets("MNIST_data/",one_hot=True)trX, trY, teX, t...原创 2018-06-05 10:01:23 · 237 阅读 · 0 评论 -
使用cifar-10数据集
#-*-coding:utf-8-*-import numpy as npimport matplotlib.pyplot as pltfrom data_utils import load_CIFAR10cifar10_dir = 'datasets/cifar-10-batches-py'X_train, y_train, X_test, y_test = load_CIFAR10(...原创 2018-05-29 20:22:46 · 3406 阅读 · 0 评论 -
显式循环计算损失函数
#-*-coding:utf-8-*-import numpy as npimport timeimport matplotlib.pyplot as pltfrom data_utils import load_CIFAR10,get_CIFAR10_datacifar10_dir = 'datasets/cifar-10-batches-py'X_train, y_train, X...原创 2018-05-29 22:05:18 · 354 阅读 · 0 评论 -
卷积神经网络的应用实例-LeNet5网络结构
#encoding:utf-8import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_dataimport time#获取mnist数据mnist_data_set = input_data.read_data_sets('MNIST_data', one_hot=True)#声明输...原创 2018-07-18 10:37:26 · 796 阅读 · 0 评论 -
程序的重构--模块化设计
#encoding:utf-8import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_dataimport timeimport matplotlib.pyplot as pltdef weight_variable(shape): initial = tf.truncated_n...原创 2018-07-18 11:29:52 · 460 阅读 · 0 评论 -
使用循环神经网络实现语言模型
#coding:utf-8from tensorflow.models.rnn.ptb import readerimport tensorflow as tfimport numpy as npDATA_PATH = "./simple-examples/data"#读取原始数据# print (len(train_data))# result = reader.ptb...原创 2018-07-27 17:29:31 · 935 阅读 · 0 评论 -
预测正弦函数
# -*- coding: utf-8 -*-# 以下程序为预测离散化之后的sin函数import numpy as npimport tensorflow as tffrom tensorflow.contrib import rnn# 加载matplotlib工具包,使用该工具包可以对预测的sin函数曲线进行绘图import matplotlib as mplfrom te...原创 2018-07-27 18:16:58 · 950 阅读 · 0 评论 -
BP神经网络Python实现
# encoding:utf-8import numpy as npimport mathimport randomdef rand(a, b): return (b-a)*random.random() + adef make_matrix(m, n, fill=0.0): mat = [] for i in range(m): mat.ap...原创 2018-10-13 17:54:18 · 932 阅读 · 0 评论 -
进阶的卷积网络
# -*- coding:utf-8 -*-import cifar10,cifar10_inputimport tensorflow as tfimport numpy as npimport timemax_steps = 3000batch_size = 128data_dir = '/tmp/cifar10_data/cifar-10-batches-bin'def va...原创 2018-05-29 11:03:19 · 209 阅读 · 0 评论 -
使用不同卷积核对图像进行处理之后的效果
# -*- coding: utf-8 -*-import cv2import numpy as npimport matplotlib.pyplot as pltsrc = cv2.imread("09-opencv/lena.jpg")kernels = [ (u"低通滤波器", np.array([[1, 1, 1], [1, 2, 1], [1, 1, 1]]) * 0...原创 2018-05-23 21:24:02 · 5019 阅读 · 0 评论 -
简单的CNN
# -*- coding:utf-8 -*-from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfmnist = input_data.read_data_sets("MNIST_data/", one_hot=True)sess = tf.InteractiveSession()...原创 2018-05-28 15:47:16 · 421 阅读 · 0 评论 -
最佳实践样例程序
mnist_inference.py 定义了前向传播的过程以及神经网络的参数import tensorflow as tf# mnist_inference.py# 主网络构建,用于构建网络结构INPUT_NODE = 784OUTPUT_NODE = 10LAYER1_NODE = 500def get_weight_variable(shape, regularizer): ...原创 2018-05-11 11:40:08 · 183 阅读 · 0 评论 -
LeNet-5 模型
修改后的LeNet5_inferneceimport tensorflow as tfINPUT_NODE = 784OUTPUT_NODE = 10IMAGE_SIZE = 28NUM_CHANNELS = 1NUM_LABELS = 10CONV1_DEEP = 32CONV1_SIZE = 5CONV2_DEEP = 64CONV2_SIZE = 5F...原创 2018-05-11 16:08:12 · 292 阅读 · 1 评论 -
通过集合计算一个5层神经网络带L2正则化的损失函数的计算方法
import tensorflow as tf#获取一层神经网络边上的权重,并将这个权重的L2正则化损失加入名称为'losses'的集合中def get_weight(shape, lambda): #生成一个变量 var = tf.Variable(tf.random_normal(shape), dtype = tf.float32) #add_to_c...原创 2018-04-27 17:28:47 · 596 阅读 · 0 评论 -
Word2Vec
#encoding:utf-8import collectionsimport mathimport osimport randomimport zipfileimport numpy as npimport urllibimport tensorflow as tf# url = 'http://mattmahoney.net/dc/'# def maybe_download...原创 2018-05-20 18:50:50 · 264 阅读 · 0 评论 -
神经网络解决二分类问题
import tensorflow as tffrom numpy.random import RandomStatebatch_size = 8w1 = tf.Variable(tf.random_normal([2, 3], stddev=1, seed=1))w2 = tf.Variable(tf.random_normal([3, 1], stddev=1, seed=1))...原创 2018-04-27 10:45:00 · 1769 阅读 · 0 评论 -
tensorflow实现自编码器
# -*- coding:utf-8 -*-import numpy as npimport sklearn.preprocessing as prepimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datadef xavier_init(fan_in, fan_out, const...原创 2018-05-28 11:29:07 · 405 阅读 · 0 评论 -
Bi-RNN
#coding:utf-8#代码主要是使用Bidirectional LSTM Classifier对MNIST数据集上进行测试#导入常用的数据库,并下载对应的数据集import tensorflow as tfimport numpy as npfrom tensorflow.examples.tutorials.mnist import input_datamnist = inpu...原创 2018-05-23 15:57:32 · 1857 阅读 · 0 评论 -
LSTM语言模型
#coding:utf-8#导入常用的库,模型中的PTB reader主要是借助它读取数据内容,并把单词转为唯一的数字编码,以便神经网络处理from __future__ import divisionimport timeimport numpy as npimport tensorflow as tfimport reader#定义语言模型处理输入数据的classclass...原创 2018-05-23 16:33:49 · 1280 阅读 · 0 评论 -
多层感知机
# -*- coding:utf-8 -*-from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfmnist = input_data.read_data_sets("MNIST_data", one_hot=True)sess = tf.InteractiveSession()...原创 2018-05-28 14:50:41 · 286 阅读 · 0 评论 -
LeNet5
# -*- coding:utf-8 -*-import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_dataimport time#声明输入图片数据,类别x = tf.placeholder('float', [None, 784])y_ = tf.placeholder('float'...原创 2018-10-14 11:06:48 · 215 阅读 · 0 评论