MrGemy95/Tensorflow-Project-Template

I think might some problem here

HannH opened this issue · 1 comments

HannH commented

self.train_step = tf.train.AdamOptimizer(self.config.learning_rate).minimize(self.cross_entropy,

I think it maybe not good idea writing optimizer there. Programer need to shrink the model size when release a well trained model. Sometimes we may want to save variables except optimizer like this:

net = ExampleModel.build_model(...)#only net defines inside
saver = tf.train.Saver()
with tf.Session() as sess:
    saver.restore(sess, model_path)
    ...
    do something to resave model for shrink size
    ...

It will be trouble in such situation when you put the model defines and optmizer together

Programer need to shrink the model size when release a well trained model.

This's right, but separating the train_step form the model isn't the only solution, that's why i left "init_saver" not implemented so you can easily give it the list of variables you want to save. in this case simply exclude the optimizer variables from the list you give to the tensorflow saver.