Open rainit2006 opened 7 years ago
基础知识
莫烦教学 https://www.youtube.com/watch?v=HhjtJ73AwIY&index=9&list=PLXO45tsB95cKI5AIlf5TxxFPzb-0zeVZ8
Tensor Ranks, Shapes, and Types
[[1., 2., 3.], [4., 5., 6.]] # a rank 2 tensor; a matrix with shape [2, 3]
[[[1., 2., 3.]], [[7., 8., 9.]]] # a rank 3 tensor with shape [2, 1, 3]。看3维的元素数量是2;2维的元素数量是1;1维的元素数量是3。
Session Must run the computational graph within a session. A session encapsulates the control and state of the TensorFlow runtime.
sess = tf.Session()
print(sess.run([node1, node2]))
placeholder データが格納される予定地です。データは未定のままグラフを構築し、具体的な値は実行するときに与えます。 プレースホルダーの値は、オペレーションの実行時にfeed_dictを通じて与えます。
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
result = sess.run(mul_op, feed_dict={
holder2: 5
})
print(result)
tf.train API 提供了一组训练算法和类。
激励函数(activation function)、活性化関数 激励函数:有人说翻译成“激活函数”(activation function)会更好,因为主要作用是分割数据,判断该“神经”是否被激活。 激活函数是用来加入非线性因素的,解决线性模型所不能解决的问题。
tf.nn.relu(features, name = None) 这个函数的作用是计算激活函数relu,即max(features, 0)
gradientdescentoptimizer函数 实现了梯度下降算法。使用梯度下降法找到一个函数的局部极小值。常用于机器学习和人工智能当中用来递归性地逼近最小偏差模型。 个人理解是该算法可以让预测值和实际值的偏差最小,找到所对应了参数(W, b)
举一个非常简单的例子,如求函数 的最小值。
注意: 在Windows7环境下,安装tensorflow后import tensorflow时发生错误: ImportError: DLL load failed.
对策办法:安装tensorflow 1.5版本 pip install tensorflow==1.5