Training the Model - 2.0 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
Release Date
2.0 English

To train the model, create a file named and add following code:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import tensorflow as tf
from train_eval_utils import ConvNet
    'save_ckpt', '', 'Where to save checkpoint.')

def main(unused_argv):
  tf.logging.set_verbosity(tf.logging.INFO)"Training model from scratch")
  net = ConvNet(True)
  net.train_eval(10, FLAGS.save_ckpt)

if __name__ == '__main__':

Run in shell:

$ WORKSPACE=./models
$ BASELINE_CKPT=${WORKSPACE}/train/model.ckpt
$ mkdir -p $(dirname "${BASELINE_CKPT}")
$ python --save_ckpt=${BASELINE_CKPT}

The running output log looks like this:

INFO:tensorflow:time:2019-01-09 16:14:44
INFO:tensorflow:Loss at step 500: 421.8246154785156
INFO:tensorflow:Loss at step 600: 305.761474609375
INFO:tensorflow:Loss at step 700: 167.25115966796875
INFO:tensorflow:Loss at step 800: 399.25732421875
INFO:tensorflow:Loss at step 900: 246.51300048828125
INFO:tensorflow:Average loss at epoch 1: 390.06004813383385
INFO:tensorflow:train one epoch took: 2.353825569152832 seconds
INFO:tensorflow:Evaluation took: 0.22740554809570312 seconds
INFO:tensorflow:Accuracy : 0.9435

After a few minutes, a trained checkpoint is generated: models/train/model.ckpt.