Tensorflow Code2
来源:互联网 发布:现在能开通淘宝直播吗 编辑:程序博客网 时间:2024/05/22 21:12
参考资料,莫烦的tensorflow讲解传送门,以下是对他讲解的总结。
代码2
# View more python tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.com/pythontutorial"""Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly."""from __future__ import print_functionimport tensorflow as tfimport numpy as np# create datax_data = np.random.rand(100).astype(np.float32)y_data = x_data*0.1 + 0.3### create tensorflow structure start ###Weights = tf.Variable(tf.random_uniform([1], -1.0, 1.0))biases = tf.Variable(tf.zeros([1]))y = Weights*x_data + biasesloss = tf.reduce_mean(tf.square(y-y_data))optimizer = tf.train.GradientDescentOptimizer(0.5)train = optimizer.minimize(loss)init = tf.global_variables_initializer()### create tensorflow structure end ###sess = tf.Session()sess.run(init)for step in range(201): sess.run(train) if step % 20 == 0: print(step, sess.run(Weights), sess.run(biases))
tensorflow的代码需要定义图结构
再init,采用方法如下
init = tf.global_variables_initializer()
之后建立一个Session,再对于Session.run(init),再Session.run(train)才算是真正开始运行程序了。
0 0
- Tensorflow Code2
- code2
- code2
- code2
- CUDA-CODE2-分配内存
- uva 10603 Fill code2
- uva 1354 Mobile Computing code2
- Code2 读书笔记 (更新第一二部分)
- Code2 将byte数组转换为字符串
- 进程通信-共享内存-mmap()-code2
- uva 12333 Revenge of Fibonacci code2
- uva 1601 The Morning after Halloween code2
- 第2章 K近邻算法 代码code2-1 解析
- tensorflow
- TensorFlow
- TensorFlow
- tensorflow
- tensorflow
- 编译curl for android
- 回溯法
- VS C++ win32 更改static文本字体和文本背景
- 米国未来10年
- 设计模式学习——外观模式(Facade)
- Tensorflow Code2
- 211
- 如何将Excel表格中的数据粘贴到记事本中,且每列间距都为一个空格?
- 改变疲乏
- 基于Mapbox+osrm的iOS离线导航解决方案
- salt
- ViewPager无限轮滚
- 咖啡
- MAVEN常用命令