Saturday, 31 August 2019

How to save and load selected variables in tensorflow 2.0 using tf.train.Checkpoint?

How do I save selected variables in tensorflow 2.0 shown below in a file and load them into some defined variables in another code?

class manyVariables:
    def __init__(self):
        self.initList = [None]*100
        for i in range(100):
            self.initList[i] = tf.Variable(tf.random.normal([5,5]))
        self.makeSomeMoreVariables()

    def makeSomeMoreVariables(self):
        self.moreList = [None]*10
        for i in range(10):
            self.moreList[i] = tf.Variable(tf.random.normal([3,3]))

    def saveVariables(self):
        # how to save self.initList's 3,55 and 60th elements and self.moreList's 4th element

What is the most tf2 specific way to save variables and restore them?



from How to save and load selected variables in tensorflow 2.0 using tf.train.Checkpoint?

No comments:

Post a Comment