我爱编程

tensorflow基础篇

2017-05-26  本文已影响0人  夜尽天明时

写在前面

tensorflow的一般建模步骤:

损失函数

Tensors的声明方式

variable的声明

Matrices矩阵操作

  identity_matrix = tf.diag([1.0, 1.0, 1.0])
  A = tf.truncated_normal([2, 3])
  B = tf.fill([2,3], 5.0)
  C = tf.random_uniform([3,2])
  D = tf.convert_to_tensor(np.array([[1., 2., 3.],[-3., -7.,-1.],[0., 5., -2.]]))
  print(sess.run(identity_matrix))
  [[ 1. 0. 0.]
   [ 0. 1. 0.]
   [ 0. 0. 1.]]
  print(sess.run(A))
  [[ 0.96751703 0.11397751 -0.3438891 ]
  [-0.10132604 -0.8432678 0.29810596]]
  print(sess.run(B))
  [[ 5. 5. 5.]
  [ 5. 5. 5.]]
  print(sess.run(C))
  [[ 0.33184157 0.08907614]
  [ 0.53189191 0.67605299]
  [ 0.95889051 0.67061249]]
  print(sess.run(D))
  [[ 1. 2. 3.]
   [-3. -7. -1.]
   [ 0. 5. -2.]]

Operations的声明

tensorflow常用数学函数 tensorflow特殊函数

# Tangent function (tan(pi/4)=1)
print(sess.run(tf.div(tf.sin(3.1416/4.), tf.cos(3.1416/4.))))
1.0

Activation functions of softplus, ReLU, ReLU6, and exponential LU Sigmoid, hyperbolic tangent (tanh), and softsign activation function

好了,基础性的东西介绍就先到这里,可否赞一个?你的支持就是我的动力!

上一篇下一篇

猜你喜欢

热点阅读