Example: use a learning rate that's 1.0 for the first 100001 steps, 0.5
for the next 10000 steps, and 0.1 for any additional steps.
global_step=tf.Variable(0,trainable=False)boundaries=[100000,110000]values=[1.0,0.5,0.1]learning_rate=tf.compat.v1.train.piecewise_constant(global_step,boundaries,values)# Later, whenever we perform an optimization step, we increment global_step.
Args
x
A 0-D scalar Tensor. Must be one of the following types: float32,
float64, uint8, int8, int16, int32, int64.
boundaries
A list of Tensors or ints or floats with strictly
increasing entries, and with all elements having the same type as x.
values
A list of Tensors or floats or ints that specifies the values
for the intervals defined by boundaries. It should have one more element
than boundaries, and all elements should have the same type.
name
A string. Optional name of the operation. Defaults to
'PiecewiseConstant'.
Returns
A 0-D Tensor. Its value is values[0] when x <= boundaries[0],
values[1] when x > boundaries[0] and x <= boundaries[1], ...,
and values[-1] when x > boundaries[-1].
Raises
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.
When eager execution is enabled, this function returns a function which in
turn returns the decayed learning rate Tensor. This can be useful for changing
the learning rate value across different invocations of optimizer functions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-23 UTC."],[],[]]