Tensor flow 实战Google深度学习框架 笔记Code Part

深层神经网络

线性模型的局限性

激活函数实现去线性化

a=tf.nn.relu(tf.matmul(x,w1)+biases1)
y=tf.nn.relu(tf.matmul(a,w2)+biases2)

经典损失函数

#计算交叉熵
cross_entropy=-tf.reduce_mean(
                  y_*tf.log(tf.clip_by_value(y,le-10,1.0)))
#tf.clip_by_value 样例
v=tf.constant([1.0,2.0,3.0],[4.0,5.0,6.0])
print tf.clip_by_value(v,2.5,4.5).eval()
#输出 [[2.5,2.5,3],[4.0,4.5,4.5]]

如果你有一个Tensor t,在使用t.eval()时,等价于:tf.get_default_session().run(t).

#tf.log()样例 对数计算
v = tf.constant([1.0,2.0,3.0])
print tf.log(v).eval()
#输出。。。。 

猜你喜欢

转载自www.cnblogs.com/IAMzhuxiaofeng/p/9029604.html
今日推荐