tensorflow-Alexnet学习笔记

来源:互联网 发布:linux snmp 协议版本 编辑:程序博客网 时间:2024/04/29 21:27

1.关于Alexnet网络。
1)卷积滤波器大小一般为奇数,如11×11,5×5,3×3;
2)stride为卷积步幅,一般为4×4,2×2,1×1;
3)padding为步长移动方式,有两种参数,分别为Valid和Same,Valid表示步长移动的时候不越过图像边
缘,Same表示步长移动的时候包含图像边缘,两种图像大小计算方式分别为:
valid:(piexl-kernel)/stride+1
same:(piexl-kernel+kernel/2*2)/stride+1
2.关于loss。
y=tf.nn.softmax(tf.matmul(x,W)+b) y为real output,y_为predict output
1)对数似然函数作为交叉熵
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
首先,用 tf.log 计算 y 的每个元素的对数.接下来,我们把 y_ 的每一个元素和 tf.log(y) 的对应元素相乘.最后,用 tf.reduce_sum 计算张量的所有元素的总和.
2)交叉熵代价函数
cost =tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y_, y))
函数原型:tf.nn.softmax_cross_entropy_with_logits(logits, labels, name=None),compute cross entropy between logits and labels.logits and labels must have the same shape [batch_size, num_classes] and the same dtype (either float32 or float64 ).
3) loss = tf.reduce_mean(tf.square(y − y_))

0 0