DynamicValue

class tfsnippet.DynamicValue

Bases: object

Dynamic values to be fed into trainers and evaluators.

For example, if you want to feed a learning rate into trainer, which shrinks into half every 100 epochs, you may use the following code:

class MyLearningRate(spt.DynamicValue):

    def __init__(self, loop):
        self.loop = loop

    def get(self):
        return 0.001 * int(self.loop.epoch // 100) * 0.5

learning_rate = tf.placeholder(dtype=tf.float32, shape=())
...

with spt.TrainLoop(...) as loop:
    trainer = spt.Trainer(
        ...,
        feed_dict={learning_rate: MyLearningRate(loop)}
    )
    trainer.run()

Or you may also use AnnealingScalar, a class that has already implemented such behaviour.

Methods Summary

get() Get the current value of this DynamicValue object.

Methods Documentation

get()

Get the current value of this DynamicValue object.