【tensorflow(三十七):卷积神经网络——CIFAR100与VGG实战】教程文章相关的互联网学习教程文章

tensorflow 神经网络模型概览;熟悉Eager 模式;【图】

典型神经网络模型:(图片来源:https://github.com/madalinabuzau/tensorflow-eager-tutorials) 保持更新,更多内容请关注 cnblogs.com/xuyaowen;原文:https://www.cnblogs.com/xuyaowen/p/tensorflow-nn-Eager.html

tensorflow学习之(七)使用tensorboard 展示神经网络的graph/histogram/scalar【代码】【图】

# 创建神经网络, 使用tensorboard 展示graph/histogram/scalarimport tensorflow as tf import numpy as np import matplotlib.pyplot as plt # 若没有 pip install matplotlib# 定义一个神经层def add_layer(inputs, in_size, out_size,n_layer, activation_function=None):#add one more layer and return the output of this layerlayer_name="layer%s"%n_layerwith tf.name_scope(layer_name):with tf.name_scope(‘Weights‘...

跟我学算法- tensorflow 卷积神经网络训练验证码【代码】

使用captcha.image.Image 生成随机验证码,随机生成的验证码为0到9的数字,验证码有4位数字组成,这是一个自己生成验证码,自己不断训练的模型使用三层卷积层,三层池化层,二层全连接层来进行组合第一步:定义生成随机验证码图片number = [‘0‘,‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘] # alphabet = [‘a‘,‘b‘,‘c‘,‘d‘,‘e‘,‘f‘,‘g‘,‘h‘,‘i‘,‘j‘,‘k‘,‘l‘,‘m‘,‘n‘,‘o‘,‘p‘,‘q‘,‘...

吴裕雄 python 神经网络——TensorFlow实现AlexNet模型处理手写数字识别MNIST数据集【代码】【图】

import tensorflow as tf# 输入数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("E:\\MNIST_data", one_hot=True)# 定义网络的超参数 learning_rate = 0.001 training_iters = 200000 batch_size = 128 display_step = 5# 定义网络的参数 # 输入的维度 (img shape: 28*28) n_input = 784 # 标记的维度 (0-9 digits) n_classes = 10 # Dropout的概率,输出的可能性 dropout = ...

基于TensorFlow框架实现人工神经网络完成手写数字识别任务【多测师】【代码】【图】

使用人工神经网络完成手写数字识别任务。具体要求如下: (1)batch_size和step_num自定义,把loss值打印出来。 (2)神经网络的层数、节点数目、激活函数自定义。(记录心得) (3)使用tensorboard把计算图显示出来。一、初始数据如下:batch_size=64lr = 0.01 #学习率step_num = 6000 #计算6000次计算的神经元层数是3层使用的是随机梯度下降算法 tf.train.GradientDescentOptimizer()计算出来的准确度为:0.717 二、参数调优过程...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用自动编解码网络实现黑白图片上色【代码】【图】

加载cifar10图片集并准备将图片进行灰度化 from keras.datasets import cifar10def rgb2gray(rgb):#把彩色图转化为灰度图,如果当前像素点为[r,g,b],那么对应的灰度点为0.299*r+0.587*g+0.114*breturn np.dot(rgb[...,:3], [0.299, 0.587, 0.114])(x_train, _),(x_test, _) = cifar10.load_data()img_rows = x_train.shape[1] img_cols = x_train.shape[2] channels = x_train.shape[3]#将100张彩色原图集合在一起显示 imgs = x_t...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:RNN-具有记忆功能的神经网络【代码】【图】

from keras.layers import SimpleRNN model = Sequential() model.add(embedding_layer) model.add(SimpleRNN(32)) #当结果是输出多个分类的概率时,用softmax激活函数,它将为30个分类提供不同的可能性概率值 model.add(layers.Dense(len(int_category), activation=softmax))#对于输出多个分类结果,最好的损失函数是categorical_crossentropy model.compile(optimizer=rmsprop, loss=categorical_crossentropy, metrics=[accurac...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:LSTM网络层详解及其应用【代码】【图】

from keras.layers import LSTM model = Sequential() model.add(embedding_layer) model.add(LSTM(32)) #当结果是输出多个分类的概率时,用softmax激活函数,它将为30个分类提供不同的可能性概率值 model.add(layers.Dense(len(int_category), activation=softmax))#对于输出多个分类结果,最好的损失函数是categorical_crossentropy model.compile(optimizer=rmsprop, loss=categorical_crossentropy, metrics=[accuracy]) histor...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:RNN和CNN混合的鸡尾酒疗法提升网络运行效率【代码】【图】

from keras.layers import model = Sequential() model.add(embedding_layer) #使用一维卷积网络切割输入数据,参数5表示每各个单词作为切割小段 model.add(layers.Conv1D(32, 5, activation=relu)) #参数3表示,上层传下来的数据中,从每3个数值中抽取最大值 model.add(layers.MaxPooling1D(3)) #添加一个有记忆性的GRU层,其原理与LSTM相同,运行速度更快,准确率有所降低 model.add(layers.GRU(32, dropout=0.1))model.add(lay...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:自动编解码器网络的原理与实现【代码】【图】

from keras.layers import Dense, Input from keras.layers import Conv2D, Flatten from keras.layers import Reshape, Conv2DTranspose from keras.models import Model from keras.datasets import mnist from keras import backend as Kimport numpy as np import matplotlib.pyplot as plt#加载手写数字图片数据 (x_train, _), (x_test, _) = mnist.load_data() image_size = x_train.shape[1]#把图片大小统一转换成28*28,并把...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:去噪型编码网络【代码】【图】

#为图像像素点增加高斯噪音 noise = np.random.normal(loc=0.5, scale = 0.5, size = x_train.shape) x_train_noisy = x_train + noise noise = np.random.normal(loc=0.5, scale = 0.5, size = x_test.shape) x_test_noisy = x_test + noise #添加噪音值后,像素点值可能会超过1或小于0,我们把这些值调整到[0,1]之间 x_train_noisy = np.clip(x_train_noisy, 0., 1.) x_test_noisy = np.clip(x_test_noisy, 0., 1.)autoencoder =...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:自然语言处理Word Embedding 单词向量化【代码】【图】

import numpy as np samples = [The cat jump over the dog, The dog ate my homework]#我们先将每个单词放置到一个哈希表中 token_index = {} for sample in samples:#将一个句子分解成多个单词for word in sample.split():if word not in token_index:token_index[word] = len(token_index) + 1#设置句子的最大长度 max_length = 10 results = np.zeros((len(samples), max_length, max(token_index.values()) + 1)) for i, samp...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:概率论的一些重要概念【代码】【图】

import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlab import mathmu = 0 variance = 1 sigma = math.sqrt(variance) x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100) plt.plot(x, mlab.normpdf(x, mu, sigma)) plt.show()import scipy, scipy.stats x = scipy.linspace(0,10,11) pmf = scipy.stats.binom.pmf(x,10,0.5) import pylab pylab.plot(x,pmf)

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:卷积神经网络的底层原理【代码】【图】

def conv_(img, conv_filter):filter_size = conv_filter.shape[1]result = numpy.zeros((img.shape))print(loop r: , numpy.uint16(numpy.arange(filter_size/2.0,img.shape[0]-filter_size/2.0+1)))#Looping through the image to apply the convolution operation.for r in numpy.uint16(numpy.arange(filter_size/2.0,img.shape[0]-filter_size/2.0+1)):for c in numpy.uint16(numpy.arange(filter_size/2.0,img.shape[1]-filt...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用神经网络预测房价中位数【代码】【图】

import pandas as pd data_path = /Users/chenyi/Documents/housing.csv housing = pd.read_csv(data_path) housing.info()housing.head()housing.describe()housing.hist(bins=50, figsize=(15,15)) housing[ocean_proximity].value_counts()import seaborn as sns total_count = housing[ocean_proximity].value_counts() plt.figure(figsize=(10,5)) sns.barplot(total_count.index, total_count.values, alpha=0.7) pl...