【发布时间】:2020-03-26 08:36:11
【问题描述】:
我想使用策略梯度在网络中的一组节点中找到最短路径。
网络使用带有标记为值 -1 的边的图表示。
现在,负值最接近 0 的路径是最短路径。
因此,我使用梯度下降来更新策略参数。
这是 TensorFlow 中的更新规则。
self.cross_entropy = tf.nn.softmax_cross_entropy_with_logits_v2(labels = self.outputTrue, logits = self.outputPred)
self.cerd = tf.tensordot(self.cross_entropy, self.reward, axes=1)
self.meanCEloss = self.cerd/tf.cast(BS,tf.float32) # BS is the batch size.
self.train_step = tf.train.AdamOptimizer(1e-4).minimize(self.meanCEloss)
但是,在运行代码后,self.meanCEloss 会不断向负无穷大减小,直到发生下溢。
损失评估需要做哪些改变才能解决问题?
【问题讨论】:
标签: python-3.x tensorflow shortest-path reinforcement-learning policy-gradient-descent