ValueError: Градиенты не предусмотрены для любой переменной в функции потерь - PullRequest
0 голосов
/ 11 апреля 2020

Я очень новичок в тензорном потоке.

prob = tf.nn.softmax_cross_entropy_with_logits(logits = self.output_layer_predictions_array, labels = y)
loss = tf.matmul( [prob] ,discounted_episode_rewards_)[0] 
train_opt = self.sess.run(tf.train.AdamOptimizer().minimize(loss))

Образцы self.output_layer_predictions_array

[[-3.6822972297668457, 0.3711770176887512], [-0.8316356539726257, 0.9947062134742737],...

y

[[0.01706565 0.98293436]
 [0.13867462 0.8613254 ]..

потеря

[0.08638819 0.40255022 0.20361374 0.4243075  0.5737337  0.68438727
 0.6912215  0.69195086 0.65356493 0.5951165  0.6025962 ]

То, что я исследовал и обнаружил, было у должно составлять до 1 У меня есть отлично рассчитанные потери

Но это дает ошибку

> ValueError: No gradients provided for any variable, check your graph
> for ops that do not support gradients, between variables
> ["<tf.Variable 'Variable:0' shape=(4, 24) dtype=float32_ref>",
> "<tf.Variable 'Variable_1:0' shape=(24,) dtype=float32_ref>",
> "<tf.Variable 'Variable_2:0' shape=(24, 12) dtype=float32_ref>",
> "<tf.Variable 'Variable_3:0' shape=(12,) dtype=float32_ref>",
> "<tf.Variable 'Variable_4:0' shape=(12, 4) dtype=float32_ref>",
> "<tf.Variable 'Variable_5:0' shape=(4,) dtype=float32_ref>",
> "<tf.Variable 'Variable_6:0' shape=(4, 2) dtype=float32_ref>"] and
> loss Tensor("strided_slice:0", shape=(1,), dtype=float32).

Я не могу решить эту ошибку. Пожалуйста, помогите и спросите, если что-то нужно

...