Tensorflow
隐终
这人很懒,没留下什么
展开
-
HelloWorld
使用tensorflow库写helloWorldimport tensorflow as tf #创建一个常量 hw = tf.constant("Hello World") #启动一个TensorFlow的session sess = tf.Session() #运行 Graph print sess.run(hw) #关闭 Session sess.close()运行后,将会显示一句话...原创 2018-03-21 12:39:17 · 108 阅读 · 0 评论 -
TensorFlow常用库NumPy
官网教程:https://docs.scipy.org/doc/numpy-dev/user/quickstart.html首先要注意一句话:NumPy’s main object is the homogeneous multidimensional array翻译过来就是,numpy库的主要对象是多维数组,0、1、2、3.....特征:ndarray.ndim:该对象的维度ndarray.sh...原创 2018-03-21 13:11:23 · 492 阅读 · 0 评论 -
Graph和Session的小案例
import tensorflow as tf #创建一个常量 c = tf.constant( [[2,3],[4,5]],name="const1",dtype=int64 ) #输出c:<tf.Tensor 'const1:0' shape=(2,2) dtype=int64> #创建会话,需要关闭 sess = tf.Session() sess.run(c) ''' ...原创 2018-03-21 17:12:32 · 203 阅读 · 0 评论 -
TensorBoard的运用
使用方式:1、用TensorFlow保存图的信息到日志中tf.summary.FileWriter("路径",sess.graph)2、用TensorBoard读取并展示日志tensorboard --logdir=路径TensorBoard图标:eg:tensorboard --logdir=/tmp/hello(要注意的是,浏览器会使用6006端口)import tensorflow as t...原创 2018-03-21 20:40:12 · 219 阅读 · 0 评论 -
matplotlib的使用
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-4,4,50) y1 = x * 2 +1 y2 = x*x + 10 #创建第一张图表 #plot,画线 #figsize:生成图的初始大小 plt.figure(num=1,figsize=(7,6)) plt.plot(x,y1) plt.plot(x,...原创 2018-03-21 21:37:58 · 126 阅读 · 0 评论 -
梯度下降
梯度下降算是机器学习的核心优化算法了。tensorflow的运算操作import numpy as numpy import matplotlib.pyplot as plt import tensorflow as tf #构建数据 points_num = 100 vectors = [] for i in xrange(points_num): x1 = np.random.normal...原创 2018-03-21 22:41:17 · 150 阅读 · 0 评论 -
常用的激活函数
#activation function import numpy as np import matplotlib.pyplot as plt import tensorflow as tf x = np.linsoace(-7,7,180) def sigmoid(inputs): y = [ 1 / float(1 + np.exp(-x)) for x in inputs ] re...原创 2018-03-22 11:01:39 · 218 阅读 · 0 评论