keras与tensorflow

以下是为您整理出来关于【keras与tensorflow】合集内容,如果觉得还不错,请帮忙转发推荐。

【keras与tensorflow】技术教程文章

吴裕雄--天生自然神经网络与深度学习实战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...

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

from keras import layers from keras import modelsmodel = models.Sequential() #首层接收2维输入 model.add(layers.Conv2D(32, (3,3), activation=relu, input_shape=(28,28,1))) model.add(layers.MaxPooling2D(2,2)) model.add(layers.Conv2D(64, (3,3), activation=relu)) model.add(layers.MaxPooling2D((2,2))) model.add(layers.Conv2D(64, (3,3), activation=relu))model.add(layers.Flatten()) model.add(layers.Dense(...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:实现分析电影评论正负能量【代码】【图】

from keras.datasets import imdb #num_words表示加载影评时,确保影评里面的单词使用频率保持在前1万位,于是有些很少见的生僻词在数据加载时会舍弃掉 (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)print(train_data[0]) print(train_labels[0])#频率与单词的对应关系存储在哈希表word_index中,它的key对应的是单词,value对应的是单词的频率 word_index = imdb.get_word_index() #我...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用TensorFlow和Keras开发高级自然语言处理系统——LSTM网络原理以及使用LSTM实现人机问答系统【代码】【图】

!mkdir /content/gdrive/My Drive/conversation 将文本句子分解成单词,并构建词库 path = /content/gdrive/My Drive/conversation/ with open(path + question.txt, r) as fopen:text_question = fopen.read().lower().split(\n) with open(path + answer.txt, r) as fopen:text_answer = fopen.read().lower().split(\n)concat_question = .join(text_question).split() vocabulary_size_question = len(list(set(concat_questi...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:Bellman函数、贪心算法与增强性学习网络开发实践【代码】【图】

!pip install gym import random import numpy as np import matplotlib.pyplot as plt from keras.layers import Dense, Dropout, Activation from keras.models import Sequential from keras.optimizers import Adam from keras import backend as K from collections import deque import gym#选取互动环境 env = gym.make(CartPole-v1) state = env.reset()#0或1表示让小车向不同方向移动 action = 0 #step(action)表示想环...