文章目录

  • 目录
    • 1.神经网络知识概览
      • 1.1深度学习顶会
      • 1.2相关比赛
      • 1.3神经网络知识概览
      • 1.4神经网络编程一般实现过程
    • 2.简单神经网络ANN
      • 2.1 数据集:
      • 2.2 网络结构:
      • 2.3 代码实现
        • 2.3.1 读取数据,并做处理
        • 2.3.2 构建网络结构
        • 2.3.3 训练网络

目录

1.神经网络知识概览

1.1深度学习顶会

  • CVPR : IEEE Conference on Computer Vision and Pattern Recognition

    • CVPR是计算机视觉与模式识别顶会
  • ICCV:IEEE International Conference on Computer Vision
    • ICCV论文录用率非常低,是三大会议中公认级别最高的
  • ECCV:European Conference on Computer Vision

1.2相关比赛

1.ImageNet

  • ImageNet 数据集最初由斯坦福大学李飞飞等人在 CVPR 2009 的一篇论文中推出


  • 2.webvision

1.3神经网络知识概览


1.4神经网络编程一般实现过程

1.数据预处理
2.定义神经网络结构
3.初始化网络模型中的参数
4.开始训练模型

loop(number_iterations):forward propagationcompute costbackward propagationupdate parameters

5.对新的数据进行预测

2.简单神经网络ANN

2.1 数据集:

  • 训练集 + 测试集
  • 训练集:训练集 + 评估集


  • 数据信息:

2.2 网络结构:

  • 网络结构 linear -> relu -> linear -> relu -> linear -> softmax
  • 网络结构12288 -> 25 -> 12 -> 6
  • 迭代次数1000,学习率0.0001,minibatch_size=32,优化算法Adam
  • 将RGB图片转换为向量(损失空间结构信息)
  • 出现过拟合,应该使用正则化(L2、Dropout、早停)

2.3 代码实现

2.3.1 读取数据,并做处理

import math
import h5py
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import scipy
from PIL import Image
from scipy import ndimage
from tensorflow.python.framework import ops
from improv_utils import *%matplotlib inline
np.random.seed(1)# 下载数据
X_train_orig, Y_train_orig, X_test_orig, Y_test_orig, classes = load_dataset()# 显示图片
index = 2
plt.imshow(X_train_orig[index])
plt.show()
print("y = " + str(np.squeeze(Y_train_orig[:, index])))# 将数据平铺,归一化,标签one-hot
X_train_flatten = X_train_orig.reshape(X_train_orig.shape[0], -1).T
X_test_flatten  = X_test_orig.reshape(X_test_orig.shape[0], -1).TX_train = X_train_flatten/255.
X_test  = X_test_flatten/255.Y_train = convert_to_one_hot(Y_train_orig, 6)
Y_test  = convert_to_one_hot(Y_test_orig, 6)print ("number of training examples = " + str(X_train.shape[1]))
print ("number of test examples = " + str(X_test.shape[1]))
print ("X_train shape: " + str(X_train.shape))
print ("Y_train shape: " + str(Y_train.shape))
print ("X_test shape: " + str(X_test.shape))
print ("Y_test shape: " + str(Y_test.shape))

y = 2
number of training examples = 1080
number of test examples = 120
X_train shape: (12288, 1080)
Y_train shape: (6, 1080)
X_test shape: (12288, 120)
Y_test shape: (6, 120)

2.3.2 构建网络结构

# 1-1、创建占位符
def create_placeholders(n_x, n_y):"""Creates the placeholders for the tensorflow session.Arguments:n_x -- scalar, size of an image vector (num_px * num_px = 64 * 64 * 3 = 12288)n_y -- scalar, number of classes (from 0 to 5, so -> 6)Returns:X -- placeholder for the data input, of shape [n_x, None] and dtype "float"Y -- placeholder for the input labels, of shape [n_y, None] and dtype "float"Tips:- You will use None because it let's us be flexible on the number of examples you will for the placeholders.In fact, the number of examples during test/train is different."""X = tf.placeholder(tf.float32, shape = [n_x, None])Y = tf.placeholder(tf.float32, shape = [n_y, None])return X, Y# 1-2、初始化参数
def initialize_parameters():"""Initializes parameters to build a neural network with tensorflow. The shapes are:W1 : [25, 12288]b1 : [25, 1]W2 : [12, 25]b2 : [12, 1]W3 : [6, 12]b3 : [6, 1]Returns:parameters -- a dictionary of tensors containing W1, b1, W2, b2, W3, b3"""tf.set_random_seed(1)       # so that your "random" numbers match oursW1 = tf.get_variable("W1", [25,12288], initializer = tf.contrib.layers.xavier_initializer(seed = 1))b1 = tf.get_variable("b1", [25,1],     initializer = tf.zeros_initializer())W2 = tf.get_variable("W2", [12,25],    initializer = tf.contrib.layers.xavier_initializer(seed = 1))b2 = tf.get_variable("b2", [12,1],     initializer = tf.zeros_initializer())W3 = tf.get_variable("W3", [6,12],     initializer = tf.contrib.layers.xavier_initializer(seed = 1))b3 = tf.get_variable("b3", [6,1],      initializer = tf.zeros_initializer())parameters = {"W1": W1,"b1": b1,"W2": W2,"b2": b2,"W3": W3,"b3": b3}return parameters# 1-3、TensorFlow中的前向传播
# tf中前向传播停止在z3,是因为tf中最后的线性层输出是被作为输入计算loss,不需要a3
def forward_propagation(X, parameters):"""Implements the forward propagation for the model: LINEAR -> RELU -> LINEAR -> RELU -> LINEAR -> SOFTMAXArguments:X -- input dataset placeholder, of shape (input size, number of examples)parameters -- python dictionary containing your parameters "W1", "b1", "W2", "b2", "W3", "b3"the shapes are given in initialize_parametersReturns:Z3 -- the output of the last LINEAR unit"""W1 = parameters['W1']b1 = parameters['b1']W2 = parameters['W2']b2 = parameters['b2']W3 = parameters['W3']b3 = parameters['b3']Z1 = tf.add(tf.matmul(W1, X), b1)                      # Z1 = np.dot(W1, X) + b1A1 = tf.nn.relu(Z1)                                    # A1 = relu(Z1)Z2 = tf.add(tf.matmul(W2, A1), b2)                     # Z2 = np.dot(W2, a1) + b2A2 = tf.nn.relu(Z2)                                    # A2 = relu(Z2)Z3 = tf.add(tf.matmul(W3, A2), b3)                     # Z3 = np.dot(W3,Z2) + b3return Z3# 1-4、计算成本函数
def compute_cost(Z3, Y):"""Computes the costArguments:Z3 -- output of forward propagation (output of the last LINEAR unit), of shape (6, number of examples)Y -- "true" labels vector placeholder, same shape as Z3Returns:cost - Tensor of the cost function"""# to fit the tensorflow requirement for tf.nn.softmax_cross_entropy_with_logits(...,...)logits = tf.transpose(Z3)labels = tf.transpose(Y)# 函数输入:shape =(样本数,类数)# tf.reduce_mean()cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits = logits, labels = labels))return cost
def predict(X, parameters):W1 = tf.convert_to_tensor(parameters["W1"])b1 = tf.convert_to_tensor(parameters["b1"])W2 = tf.convert_to_tensor(parameters["W2"])b2 = tf.convert_to_tensor(parameters["b2"])W3 = tf.convert_to_tensor(parameters["W3"])b3 = tf.convert_to_tensor(parameters["b3"])params = {"W1": W1,"b1": b1,"W2": W2,"b2": b2,"W3": W3,"b3": b3}x = tf.placeholder("float", [12288, 1])z3 = forward_propagation(x, params)p = tf.argmax(z3)with tf.Session() as sess:prediction = sess.run(p, feed_dict = {x: X})return prediction

2.3.3 训练网络

my_image = "my_image.jpg"
fname = "images/" + my_imageimage = np.array(ndimage.imread(fname, flatten=False))
my_image = scipy.misc.imresize(image, size=(64,64)).reshape((1, 64*64*3)).T
parameters = model(X_train, Y_train, X_test, Y_test)plt.imshow(image)
plt.show()my_image_prediction = predict(my_image, parameters)
print("Your algorithm predicts: y = " + str(np.squeeze(my_image_prediction)))

深度学习(02)-- ANN学习相关推荐

  1. 深度学习02——Softmax、DNN、WideDeep Model

    说明:本系列是七月算法深度学习课程的学习笔记 1 背景介绍 深度学习在图片上的应用:功能上讲:图像分类和物体识别:应用上:可以用来分类图片:白菜形状的玉器摆件.白菜.大白菜:图片搜索:给照片打标签:识 ...

  2. AI火爆干货最全整理!五套深度学习和算法学习教程和三套Python学习视频!!!限时无套路免费领取!...

    点击蓝色"AI专栏"关注我哟 选择"星标",重磅干货,第一时间送达 这是站长第 31 期免费送丰富宝贵的干货资源与教程 本期绝对是满满的干货! 获取更多资源请关 ...

  3. python深度学习入门-与学习相关的技巧

    深度学习入门-与学习相关的技巧 博主微信公众号(左).Python+智能大数据+AI学习交流群(右):欢迎关注和加群,大家一起学习交流,共同进步! 目录 摘要 1. 参数的更新 1.1 SGD 1.2 ...

  4. Spring源码深度解析(郝佳)-学习-源码解析-基于注解注入(二)

    在Spring源码深度解析(郝佳)-学习-源码解析-基于注解bean解析(一)博客中,己经对有注解的类进行了解析,得到了BeanDefinition,但是我们看到属性并没有封装到BeanDefinit ...

  5. B站上线!DeepMind加UCL强强联手推出深度学习与强化学习进阶课程(附视频)

      新智元报道   编辑:元子 [新智元导读]DeepMind和伦敦大学学院(University College London,UCL)合作,推出了一个系列的深度学习与强化学习精品进阶课程.该课程内 ...

  6. 《预训练周刊》第39期: 深度模型、提示学习

    No.39 智源社区 预训练组 预 训 练 研究 观点 资源 活动 周刊订阅 告诉大家一个好消息,<预训练周刊>已经开启"订阅功能",以后我们会向您自动推送最新版的&l ...

  7. 深度学习未来发展的三种学习范式:混合学习,成分学习和简化学习

    深度学习是一个很大的领域,其核心是一个神经网络的算法,神经网络的尺寸由数百万甚至数十亿个不断改变的参数决定.似乎每隔几天就有大量的新方法提出. 然而,一般来说,现在的深度学习算法可以分为三个基础的学习 ...

  8. 深度强化元学习教程---元学习概述

    深度强化元学习是近期深度学习技术的一个另人瞩目的新兴领域,其利用元学习,解决了深度学习需要大数据集的问题,以及强化学习收敛慢的问题.同时元学习还可以适用于环境不断改变的应用场景,具有巨大的应用前景. ...

  9. 【深度学习】强化学习Q-Learning和DQN的应用(迷宫)

    [深度学习]强化学习Q-Learning和DQN的应用(迷宫) 文章目录 1 Q-Learning 2 例子 3 用 network 解决 4 DQN机器人走迷宫代码4.1 基础搜索算法介绍(广度优先 ...

  10. [译]深度神经网络的多任务学习概览(An Overview of Multi-task Learning in Deep Neural Networks)...

    译自:http://sebastianruder.com/multi-task/ 1. 前言 在机器学习中,我们通常关心优化某一特定指标,不管这个指标是一个标准值,还是企业KPI.为了达到这个目标,我 ...

最新文章

  1. 吴恩达《Machine Learning》Jupyter Notebook 版笔记发布!图解、公式、习题都有了
  2. guava之Stopwatch
  3. python基础-装饰器
  4. ELK学习11_ELK Stack交流群问题汇总一
  5. flink shell的local模式(benv与senv的使用+处理报错的解决方案)
  6. 易懂分布式 | Kademlia算法
  7. 面对一个全新的环境,作为一个Mysql DBA,首先应该了解什么?
  8. 04.SpringBoot 自定义配置
  9. c语言 struct 的初始化
  10. Winform实现读写IC卡Demo源码含注释
  11. python选股软件编写
  12. d3d透视逆向篇:第8课 通过虚表函数的获取D3D9函数指针
  13. 电容,电阻,二极管,三极管
  14. 淘宝新自动化测试框架AutoRobot简要介绍
  15. 神经网络各个部分的作用 彻底理解神经网络
  16. BundleFusion复现手册——Win10+VS2013+Cuda8.0+KinectV2实时重建
  17. IIS连接数和在线人数的详细说明
  18. 人脸检测工具face recognition的安装与应用
  19. java接口防止XSS攻击
  20. Uniswap深度科普

热门文章

  1. 中国的程序员为什么这么辛苦?
  2. 下列哪一项不是计算机网络的典型应用,09级计算机信息网络试卷A
  3. arcgis将点的属性赋值给面
  4. 单片机与PC机一样都是计算机,51单片机与PC机通信资料
  5. PWN-PRACTICE-BUUCTF-1
  6. REVERSE-PRACTICE-BUUCTF-5
  7. cesium坡度坡向分析_景观设计分析图制作技巧到底是什么?
  8. Mac下使用brew的常用步骤
  9. 【牛客 - 303H第十五届浙江大学宁波理工学院程序设计大赛(同步赛)】Protoss and Zerg(快速幂取模,组合数学)
  10. 1)机器学习基石笔记Lecture1:The Learning Problem