tf.train.piecewise_constant

tf.train.piecewise_constant(
    x,
    boundaries,
    values,
    name=None
)

And piecewise constant interval from the boundary value. Example: 100001 former step learning rate 1.0, 0.5 using a learning rate of 10,000 steps, the learning rate used in any other step 0.1.

global_step = tf.Variable(0, trainable=False)
boundaries = [100000, 110000]
values = [1.0, 0.5, 0.1]
learning_rate = tf.train.piecewise_constant(global_step, boundaries, values)

# Later, whenever we perform an optimization step, we increment global_step.

 

parameter:

  • x: a 0-D scalar tensor. It must be one of the following types: float32, float64, uint8, int8, int16, int32, int64.
  • boundaries: List tensor, int or float, and its entry strictly increasing, and all the elements have the same type of x.
  • values: Tensor value, integer or floating-point list of designated boundaries defined interval. It should be one more element than the boundary, and all the elements should have the same type.
  • name: A string. Optional name of the operation. The default is "PiecewiseConstant".

 

return value:

A 0-dimensional volume.

When x <= boundries [0], the value of values ​​[0];

当x > boundries[0] && x<= boundries[1],值为values[1];

......

When x> boundries [-1], the value of values ​​[-1]

 

abnormal:

  • ValueError: if types of x and boundaries do not match, or types of all values do not match or the number of elements in the lists does not match.

 

Original link: https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/train/piecewise_constant?hl=en

Guess you like

Origin blog.csdn.net/weixin_36670529/article/details/91442601