当前位置: 首页 > news >正文

茌平微网站建设北京外包seo公司

茌平微网站建设,北京外包seo公司,北京装饰公司十大排名榜,做网站需要的相关知识分类与回归 分类(Classification)与回归(Regression)的区别在于输出变量的类型。通俗理解,定量输出称为回归,或者说是连续变量预测;定性输出称为分类,或者说是离散变量预测。回归问题…

分类与回归

分类(Classification)与回归(Regression)的区别在于输出变量的类型
通俗理解,定量输出称为回归,或者说是连续变量预测;定性输出称为分类,或者说是离散变量预测。

回归问题的预测结果是连续的,通常是用来预测一个值,如预测房价、未来的天气情况等等。
一个比较常见的回归算法是线性回归算法(LR,Linear Regression)。
回归分析用在神经网络上,其最上层不需要加上softmax函数,而是直接对前一层累加即可。
回归是对真实值的一种逼近预测。

分类问题的预测结果是离散的,是用于将事物打上一个标签,通常结果为离散值。
分类通常是建立在回归之上,分类的最后一层通常要使用softmax函数进行判断其所属类别。
分类并没有逼近的概念,最终正确结果只有一个,错误的就是错误的,不会有相近的概念。
最常见的分类方法是逻辑回归(Logistic Regression),或者叫逻辑分类。

 

MNIST数据集

MNIST(Mixed National Institute of Standards and Technology database)是一个计算机视觉数据集;

  • 官方下载地址:http://yann.lecun.com/exdb/mnist/
  • 包含70000张手写数字的灰度图片,其中60000张为训练图像和10000张为测试图像;
  • 每一张图片都是28*28个像素点大小的灰度图像;

如果无法从网络下载MNIST数据集,可从官方下载,然后存放在当前脚本目录下的新建MNIST_data目录即可;

  •  MNIST_data\train-images-idx3-ubyte.gz
  • MNIST_data\train-labels-idx1-ubyte.gz
  • MNIST_data\t10k-images-idx3-ubyte.gz
  • MNIST_data\t10k-labels-idx1-ubyte.gz

 

示例程序

 1 # coding=utf-8
 2 from __future__ import print_function
 3 import tensorflow as tf
 4 from tensorflow.examples.tutorials.mnist import input_data  # MNIST数据集
 5 import os
 6 
 7 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
 8 
 9 old_v = tf.logging.get_verbosity()
10 tf.logging.set_verbosity(tf.logging.ERROR)
11 
12 mnist = input_data.read_data_sets('MNIST_data', one_hot=True)  # 准备数据(如果本地没有数据,将从网络下载)
13 
14 
15 def add_layer(inputs, in_size, out_size, activation_function=None, ):
16     Weights = tf.Variable(tf.random_normal([in_size, out_size]))
17     biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, )
18     Wx_plus_b = tf.matmul(inputs, Weights) + biases
19     if activation_function is None:
20         outputs = Wx_plus_b
21     else:
22         outputs = activation_function(Wx_plus_b, )
23     return outputs
24 
25 
26 def compute_accuracy(v_xs, v_ys):
27     global prediction
28     y_pre = sess.run(prediction, feed_dict={xs: v_xs})
29     correct_prediction = tf.equal(tf.argmax(y_pre, 1), tf.argmax(v_ys, 1))
30     accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
31     result = sess.run(accuracy, feed_dict={xs: v_xs, ys: v_ys})
32     return result
33 
34 
35 xs = tf.placeholder(tf.float32, [None, 784])  # 输入数据是784(28*28)个特征
36 ys = tf.placeholder(tf.float32, [None, 10])  # 输出数据是10个特征
37 
38 prediction = add_layer(xs, 784, 10, activation_function=tf.nn.softmax)  # 激励函数为softmax
39 
40 cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys * tf.log(prediction),
41                                               reduction_indices=[1]))  # loss函数(最优化目标函数)选用交叉熵函数
42 
43 train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)  # train方法(最优化算法)采用梯度下降法
44 
45 sess = tf.Session()
46 init = tf.global_variables_initializer()
47 sess.run(init)
48 
49 for i in range(1000):
50     batch_xs, batch_ys = mnist.train.next_batch(100)  # 每次只取100张图片,免得数据太多训练太慢
51     sess.run(train_step, feed_dict={xs: batch_xs, ys: batch_ys})
52     if i % 50 == 0:  # 每训练50次输出预测精度
53         print(compute_accuracy(
54             mnist.test.images, mnist.test.labels))

 

程序运行结果:

Extracting MNIST_data\train-images-idx3-ubyte.gz
Extracting MNIST_data\train-labels-idx1-ubyte.gz
Extracting MNIST_data\t10k-images-idx3-ubyte.gz
Extracting MNIST_data\t10k-labels-idx1-ubyte.gz
0.146
0.6316
0.7347
0.7815
0.8095
0.8198
0.8306
0.837
0.8444
0.8547
0.8544
0.8578
0.8651
0.8649
0.8705
0.8704
0.8741
0.8719
0.8753
0.8756

 

问题处理

问题现象

执行程序提示“Please use tf.data to implement this functionality.”等信息

WARNING:tensorflow:From D:/Anliven/Anliven-Code/PycharmProjects/TempTest/TempTest_2.py:13: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From C:\Users\anliven\AppData\Local\conda\conda\envs\mlcc\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Extracting MNIST_data\train-images-idx3-ubyte.gz
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From C:\Users\anliven\AppData\Local\conda\conda\envs\mlcc\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting MNIST_data\train-labels-idx1-ubyte.gz
......
......

处理方法

参考链接:https://stackoverflow.com/questions/49901806/tensorflow-importing-mnist-warnings

 

转载于:https://www.cnblogs.com/anliven/p/10434433.html

http://www.lbrq.cn/news/2737513.html

相关文章:

  • 怎么知道网站哪家公司做的关键词排名哪里查
  • 广告设计就业前景东莞搜索网络优化
  • 做视频网站推广交易链接
  • 吉安市网站制作推广普通话手抄报文字内容
  • wordpress附件下载网站整站优化推广方案
  • html 网站 模板中文seo基础入门视频教程
  • 青海高端网站建设价格百度搜索广告推广
  • 禁止wordpress自动更新优化关键词排名软件
  • 厦门做网站找哪家公司sem广告投放是做什么的
  • 出入库管理软件 免费seo流量优化
  • 如何搭建一个企业子账号网站独立站seo怎么做
  • 寻乌建设局网站邀请推广app
  • 网站怎么做才吸引人百度网站网址是多少
  • 武汉市内做网站的公司品牌建设
  • 文明网站建设方案及管理制度教育培训网站大全
  • 人社系统网站一体化建设方案seo是什么牌子
  • 老外做的汉语网站如何自己做一个网址
  • 网站可以做伦理片吗好省推广100种方法
  • 西安网站运营免费的外贸网站推广方法
  • 十四冶建设集团技工学校网站软文写作的技巧
  • 大理网站建设怎么在百度上发帖推广
  • 网站策划的重要性千牛怎么做免费推广引流
  • mvc5做博客网站百度搜索关键词排名靠前
  • 本地网站可以做吗如何创建微信小程序
  • 动态表白网站制作叶涛网站推广优化
  • 职高网站建设例题全面的seo网站优化排名
  • 单人做网站搜索引擎的网站
  • 广州seo工作室电池优化大师下载
  • 网站站点不安全电话销售如何快速吸引客户
  • 哪里有做鸭的网站企业网站建设哪家好
  • 【论文阅读】Multimodal Graph Contrastive Learning for Multimedia-based Recommendation
  • Winsows系统去除右键文件显示的快捷列表
  • Spring AMQP如何通过配置文件避免硬编码实现解耦
  • Git Revert 特定文件/路径的方法
  • 华为实验综合小练习
  • AI创业公司分析:Paloma