
深度学习4-CNN
DL
HJZ11
记录学习之路,欢迎交流
展开
-
4-CNN-demo-01-卷积核池化的api
import tensorflow as tf"""学习 卷积和池化 api"""def conv2d_answer(): with tf.Graph().as_default(): x = tf.ones(shape=[64, 32, 32, 3]) # [batch_size, height, width, channels=depth] ...原创 2019-12-24 15:09:35 · 163 阅读 · 0 评论 -
4-CNN-demo-02-激活函数和dropout使用
import tensorflow as tf"""学习 relu激活函数 和 dropout使用"""tf.set_random_seed(43)def activation_func(): with tf.Graph().as_default(): hidden_layer_weights = tf.truncated_normal(shape=[4,...原创 2019-12-28 12:11:16 · 1167 阅读 · 0 评论 -
4-CNN-demo-03_CNN网络解决手写数据集
import tensorflow as tfimport osfrom tensorflow.examples.tutorials.mnist import input_dataimport numpy as np"""用CNN来解决 手写数据集的代码。"""mnist = input_data.read_data_sets('../datas/mnist', one_hot...原创 2019-12-28 11:51:20 · 405 阅读 · 0 评论 -
4-CNN-demo-0302-权重初始化
import tensorflow as tfimport helperimport numpy as npimport matplotlib as mplfrom tensorflow.examples.tutorials.mnist import input_data# 设置字符集,防止中文乱码mpl.rcParams['font.sans-serif'] = [u'simHe...原创 2019-12-28 12:28:31 · 558 阅读 · 0 评论 -
4-CNN-demo-0401-数据增强OpenCV
import cv2import numpy as npimport matplotlib.pyplot as pltimport matplotlib as mpl# 设置字符集,防止中文乱码mpl.rcParams['font.sans-serif'] = [u'simHei']mpl.rcParams['axes.unicode_minus'] = Falsedef br...原创 2019-12-29 12:05:12 · 234 阅读 · 0 评论 -
4-CNN-demo-0402-基于TF的图像预处理相关的API
# -- encoding:utf-8 --import numpy as npimport matplotlib.pyplot as pltimport tensorflow as tf# 打印numpy的数组对象的时候,中间不省略np.set_printoptions(threshold=np.inf)def show_image(image): shape =...原创 2019-12-29 12:50:10 · 240 阅读 · 1 评论 -
4-CNN-demo-05-BN-批归一化
"""*关于代码的两点说明:*>本代码所编写的类并不代表是tensorflow最好的实践--只是为了展示批归一化。>本案例使用了MNIST数据集作为展示,但代码中设计的网络并不是作为手写字母识别用。之所以如此设计网络结构:1、忠于原论文;2、网络足够复杂,并可以展示批归一化可以加速网络训练。"""import tensorflow as tfimport tqdm...原创 2019-12-28 17:07:39 · 426 阅读 · 0 评论 -
4-CNN-demo-0502-BNorm_work
"""本小节目的:分别运用下面2种API来 完成BN的训练。并比较做了BN和 未做BN的网络的准确率的区别。1. [Batch Normalization with `tf.layers.batch_normalization`](#example_1)2. [Batch Normalization with `tf.nn.batch_normalization`](#example...原创 2019-12-28 17:19:42 · 370 阅读 · 0 评论 -
4-CNN-demo-0503-GroupNorm-分组归一化
import tensorflow as tfdef GroupNormaliztion(x, is_training, groups=32, decay=0.99, scope='gn'): """ :param x: x shape [N, H, W, C] :param is_training: bool值, 批归一化参数 :param grou...原创 2019-12-29 10:59:51 · 357 阅读 · 0 评论 -
4-CNN-demo-06-dog_ResNet50
from sklearn.datasets import load_filesfrom keras.utils import np_utilsimport numpy as npfrom glob import globimport osfrom torchvision import datasetsimport torchfrom PIL import Imageimport ...原创 2020-01-14 11:47:07 · 343 阅读 · 0 评论 -
06-Senet简单示例
import tensorflow as tf"""实现Senet block模块"""def Se_block(inputs_tensor, name, reduction=8): """ :param inputs_tensor: 4-D tensor [N, H, W, C] :param reduction: :return: """ with tf.variable_scope(name): _, H, W, C =.原创 2020-06-14 17:51:27 · 455 阅读 · 0 评论 -
07-CBAM_block注意力机制
import tensorflow as tf"""实现用于CNN的注意力机制的模块"""def cbam(inputs, reduction=8): """ 变量重用,我们使用的是 tf.AUTO_REUSE :param inputs: 输入的tensor格式为: [N, H, W, C] :param reduction: :retur...原创 2020-02-07 10:14:51 · 955 阅读 · 6 评论 -
7_MobileV3_for_cifar10.py
from utils.MobileNetOps import *from utils import helperimport pickleimport numpy as npimport tensorflow as tfimport matplotlib as mplimport os# 设置字符集,防止中文乱码mpl.rcParams['font.sans-serif']...原创 2020-02-07 10:17:54 · 583 阅读 · 0 评论 -
08_01Oxflower17花数据的读取-基于VGG牛津花迁移学习项目.py
from tflearn.datasets import oxflower17import matplotlib.pyplot as pltimport numpy as npX, Y = oxflower17.load_data( dirname='../datas/17flower', resize_pics=(224, 224), shuffle=True, one_ho...原创 2020-02-07 10:47:58 · 1278 阅读 · 0 评论 -
08_02VGG19_mat权重文件查看
from scipy import ioimport os"""# mat 是值MATLAB 的数据特征存储http://www.vlfeat.org/matconvnet/pretrained/#pretrained-models"""def get_vgg_weights(): data_path = '../datas/vgg/imagenet-vgg-veryd...原创 2020-02-07 10:53:26 · 643 阅读 · 0 评论 -
08_03基于matlab_VGG的17花_迁移学习
import osimport numpy as npimport tensorflow as tffrom scipy import iofrom tflearn.datasets import oxflower17"""基于数据集17类花,基于预训练VGG19模型进行迁移学习。# mat 是值MATLAB 的数据特征存储权重地址: http://www.vlfeat.o...原创 2020-02-07 10:57:56 · 685 阅读 · 2 评论 -
08_04基于手写数据集_mat保存模型参数
import osimport numpy as npimport tensorflow as tffrom scipy import iofrom tensorflow.examples.tutorials.mnist import input_data# 1、设置超参数learning_rate = 0.001epochs = 10batch_size = 128tes...原创 2020-02-07 10:59:12 · 227 阅读 · 0 评论 -
10_01_车牌识别数据查看.py
import tensorflow as tfimport osimport cv2import numpy as npimport matplotlib.pyplot as pltfrom genplate import GenPlate, gen_sample, charsdef make_example(image, label): """ 产生Example...原创 2020-02-07 11:14:25 · 231 阅读 · 0 评论 -
10_02车牌识别_tensorflow.py
import tensorflow as tfimport osimport cv2import numpy as npimport matplotlib.pyplot as pltfrom genplate import GenPlate, gen_sample, charsfrom utils.ops import *def create_dir_path(path): ...原创 2020-02-07 11:15:49 · 259 阅读 · 0 评论 -
10_02车牌识别_genplate.py
# coding=utf-8"""专门用于模拟数据的产生"""import PILfrom PIL import ImageFontfrom PIL import Imagefrom PIL import ImageDrawimport cv2import numpy as npimport osfrom math import *# font = ImageFont.t...原创 2020-02-07 11:16:27 · 854 阅读 · 1 评论 -
11-01手写汉字识别
import osfrom PIL import Imageimport numpy as np"""提交时间:12月22日之前, 邮箱: yingjun@ibeifeng.com要求:准确率在 93%以上。PIL 已经整合到 pillow中,需要安装pillow. 命令: pip install pillow"""image_width = 50image_height...原创 2020-02-07 11:21:32 · 281 阅读 · 1 评论