def get_lr(self, global_step):
    with tf.name_scope('lr_scheduler'):
        if (len(self.values) == 1):
            learning_rate = tf.constant(self.values[0])
        elif (len(self.values) == 2):
            cond = tf.greater(global_step, self.steps[0])
            learning_rate = tf.where(cond, self.values[1], self.values[0])
        else:
            cond_first = tf.less(global_step, self.steps[0])
            cond_between = list()
            for (ind, step) in enumerate(range(0, (len(self.steps) - 1))):
                cond_between.append(tf.logical_and(tf.less(global_step, self.steps[(ind + 1)]), tf.greater_equal(global_step, self.steps[ind])))
            cond_last = tf.greater_equal(global_step, self.steps[(- 1)])
            cond_full = [cond_first]
            cond_full.extend(cond_between)
            cond_full.append(cond_last)
            cond_vec = tf.stack(cond_full)
            lr_vec = tf.stack(self.values)
            learning_rate = tf.where(cond_vec, lr_vec, tf.zeros_like(lr_vec))
            learning_rate = tf.reduce_sum(learning_rate)
        return learning_rate
def get_lr(self, global_step):
    with tf.name_scope('lr_scheduler'):
        if (len(self.values) == 1):
            learning_rate = tf.constant(self.values[0])
        elif (len(self.values) == 2):
            cond = tf.greater(global_step, self.steps[0])
            learning_rate = tf.where(cond, self.values[1], self.values[0])
        else:
            cond_first = tf.less(global_step, self.steps[0])
            cond_between = list()
            for (ind, step) in enumerate(range(0, (len(self.steps) - 1))):
                cond_between.append(tf.logical_and(tf.less(global_step, self.steps[(ind + 1)]), tf.greater_equal(global_step, self.steps[ind])))
            cond_last = tf.greater_equal(global_step, self.steps[(- 1)])
            cond_full = [cond_first]
            cond_full.extend(cond_between)
            cond_full.append(cond_last)
            cond_vec = tf.stack(cond_full)
            lr_vec = tf.stack(self.values)
            learning_rate = tf.where(cond_vec, lr_vec, tf.zeros_like(lr_vec))
            learning_rate = tf.reduce_sum(learning_rate)
        return learning_rate