Tensorflow是目前非常流行的deeplearning框架,学习Tensorflow最好的方法是github上的tf项目https://github.com/tensorflow/tensorflow

或者阅读极客学院主导翻译的中文教程http://wiki.jikexueyuan.com/project/tensorflow-zh/how_tos/reading_data.html 。

  此处对tensorflow的基本语法不予赘述,直接贴上源码:

import numpy as np
import tensorflow as tf

#准备数据
trainX = np.linspace(-1, 1, 101)
trainY = 2 * trainX + np.random.randn(*trainX.shape) * 0.33

#定义模型
def model(X, w):
return tf.mul(X, w)

#初始化数据流图
X = tf.placeholder('float')
Y = tf.placeholder('float') w = tf.Variable(0.0, name = 'weights') y_ = model(X, w) #评估模型
cost = tf.square(Y - y_)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) sess = tf.InteractiveSession()
init = tf.initialize_all_variables()
#训练
sess.run(init)
for i in range(100):
for (x, y) in zip(trainX, trainY):
sess.run(train_op, feed_dict = {X: x, Y: y})
print sess.run(w) sess.close()

由浅入深之Tensorflow(1)----linear_regression实现的更多相关文章

  1. 由浅入深之Tensorflow(3)----数据读取之TFRecords

    转载自http://blog.csdn.net/u012759136/article/details/52232266 原文作者github地址 概述 关于Tensorflow读取数据,官网给出了三种 ...

  2. 由浅入深之Tensorflow(2)----logic_regression实现

    import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_dat ...

  3. 由浅入深之Tensorflow(4)----Saver&restore

    x = tf.placeholder(tf.float32) y = tf.placeholder(tf.float32) w = tf.Variable(tf.zeros([1, 1], dtype ...

  4. 资源 | 数十种TensorFlow实现案例汇集:代码+笔记

    选自 Github 机器之心编译 参与:吴攀.李亚洲 这是使用 TensorFlow 实现流行的机器学习算法的教程汇集.本汇集的目标是让读者可以轻松通过案例深入 TensorFlow. 这些案例适合那 ...

  5. Tensorflow之卷积神经网络(CNN)

    前馈神经网络的弊端 前一篇文章介绍过MNIST,是采用的前馈神经网络的结构,这种结构有一个很大的弊端,就是提供的样本必须面面俱到,否则就容易出现预测失败.如下图: 同样是在一个图片中找圆形,如果左边为 ...

  6. 数十种TensorFlow实现案例汇集:代码+笔记(转)

    转:https://www.jiqizhixin.com/articles/30dc6dd9-39cd-406b-9f9e-041f5cbf1d14 这是使用 TensorFlow 实现流行的机器学习 ...

  7. tensorflow 经典教程及案例

    导语:本文是TensorFlow实现流行机器学习算法的教程汇集,目标是让读者可以轻松通过清晰简明的案例深入了解 TensorFlow.这些案例适合那些想要实现一些 TensorFlow 案例的初学者. ...

  8. TensorFlow中的通信机制——Rendezvous(一)本地传输

    背景 [作者:DeepLearningStack,阿里巴巴算法工程师,开源TensorFlow Contributor] 在TensorFlow源码中我们经常能看到一个奇怪的词——Rendezvous ...

  9. AI学习---基于TensorFlow的案例[实现线性回归的训练]

    线性回归原理复习 1)构建模型               |_> y = w1x1 + w2x2 + -- + wnxn + b        2)构造损失函数               | ...

随机推荐

  1. Hadoop1.2.1 伪分布式安装

    Hadoop1.2.1 单机模式安装 Hadoop组件依赖图(从下往上看) 安装步骤: 详细步骤: 设置ssh自动登录(如下图): 1.输入命令 [ssh-keygen -t rsa],然后一直按回车 ...

  2. mySubmit.js

    function mySubmit(theForm,url,result){ function default_callback(res){ result.html(res.info); if(res ...

  3. shell脚本学习总结10--系统函数调用

    1.打印出彩色的格式 [root@new sbin]# cat demo.sh #/bin/bash . /etc/init.d/functions read -p "Pleas input ...

  4. 自定义控件_水平滑动的View 自定义属性

    保持饥饿,保持愚蠢,我们对待事情本来应该就是这样的 接下来我要写一个水平滑动的自写义,实现效果 水平滑动我们有很多种实现方法,recyceryView,HorizontalScrollView都可以, ...

  5. Git详解之二 Git细节拾遗

    git知识点详解 文件状态 现在我们手上已经有了一个真实项目的 Git 仓库,并从这个仓库中取出了所有文件的工作拷贝.接下来,对这些文件作些修改,在完成了一个阶段的目标之后,提交本次更新到仓库. 请记 ...

  6. nexus的pom配置

    <groupId>com .sms</groupId><artifactId>sms </artifactId><packaging>pom ...

  7. Linuxyum源切换阿里云软件源

    备份本机软件源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 下载新的CentOS-Bas ...

  8. tomcat------->简单配置

    主机名:www.snowing.com 域名:snowing.com http://主机+服务器端口号/path(web应用)/xxx.html 例: http://localhost:8080/it ...

  9. POSTFIX服务简介

    传统的Sendmail将所有功能都集中在同一个程序里,这种结构我们称之为“单体式设计”(monolithic).Postfix采用专职负责的策略,不同的功能分别交由不同的专门程序处理,这种结构称为“模 ...

  10. HDU_5514_Frogs

    Frogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submi ...