1.重要的概念
- tensor
- 计算图,操作(op)
- 节点,边
- variable
2.重要的函数
2.1 交叉熵损失函数
- 利用交叉熵函数计算
logits = tf.nn.xw_plus_b(tf.concat(outputs, 0), w, b)
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=tf.concat(train_labels, 0), logits=logits))
- 自己计算softmax,然后根据交叉熵公式计算
y = tf.softmax(tf.manual(x,w) + b)
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * log(y),reduction_indices=[1]))
2.2 梯度反向传播
自动计算梯度,根据梯度反向传播
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(loss)