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. Android笔记——Activity中的回传数据案例(装备选择)

    1.创建程序: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  2. SQLServer------数据类型在C#中的转换

    SQL C#tinyint bytesmallint Int16char stringint int

  3. TArray<uint8>转FString

    void ARamaUDPReceiver::Recv(const FArrayReaderPtr& ArrayReaderPtr, const FIPv4Endpoint& EndP ...

  4. uilabel 和uitextview 自适应大小

    本文转载至 http://blog.csdn.net/liulichao20/article/details/8957752 分类: ios2013-05-21 22:06 321人阅读 评论(0)  ...

  5. 使用 Apache Tiles 3 构建页面布局

    参考博客:http://aiilive.blog.51cto.com/1925756/1596059Apache Tiles是一个JavaEE应用的页面布局框架.Tiles框架提供了一种模板机制,可以 ...

  6. Linux内核态、用户态简介与IntelCPU特权级别--Ring0-3

    一.现代操作系统的权限分离: 现代操作系统一般都至少分为内核态和用户态.一般应用程序通常运行于用户态,而当应用程序调用系统调用时候会执行内核代码,此时会处于内核态.一般的,应用程序是不能随便进入内核态 ...

  7. angular4 组件间通信

    父传子用@input 子传父用@output 例:子组件 <p> <span *ngFor="let star of stars;let i=index" cla ...

  8. Django--20170905--笔记

    一.django的安装 1.先安装python 2.再安装django:pip install django 3.使用虚拟环境:pip install virtualenv 二.项目的创建 1.可以先 ...

  9. Python全栈day9(Python基础)

    Python基础 一,Windows安装Python3.5 下载地址:https://www.python.org/ftp/python/3.5.2/python-3.5.2rc1-amd64.exe ...

  10. vue下给title配置图标.ico

    在根目录下放入要作为浏览网站时看到的网页title里的图标.如 32*32 后缀为.ico的图 然后再项目中build文件夹中的,webpack.dev.conf.js文件加入一句代码,加入完重启即可 ...