1. 程式人生 > >Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted []

Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted []

tensorflow遇到問題:

ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

原因是python2轉python3後,range()返回的shape是range(0,3)而不再是list。

需要將models/research/object_detection/utils/learning_schedules.py裡的:

  rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
                                      range(num_boundaries),
                                      [0] * num_boundaries))

修改成:

  rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
                                      list(range(num_boundaries)),
                                      [0] * num_boundaries)